Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Updating Sort Order

Posted on 2007-11-19
3
Medium Priority
?
246 Views
Last Modified: 2010-03-30
I have a User Interface where user can update the SortOrdr of any products or he can add a new product and can give a user defined sort order.Multiple products can be added and sortorder field is optional. I need to persist the sort order in the database after the user clicks save.So I have listed different scenarios on how sort oder should be updated.I need to write a stable sort or some logic to make sort order unique while persisting.Can you guys tell me where should I start?


Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                    #2                           #2
                          Product 1236               #3                                    #2                           #3
                          Product 1237               #4                                    #2                            #4


Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                    #2                           #2
                          Product 1236               #3                                    #2                           #3
                          Product 1237               #4                                    #3                            #4

Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                    #2                           #2
                          Product 1236               #3                                    #3                           #4
                          Product 1237               #4                                    #4                            #5
                          Product 1238                                                  #3                              #3

Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                                                    #4
                          Product 1236               #3                                    #2                           #2
                          Product 1237               #4                                                                         #5
                          Product 1238            #5                                   #3                             #3
0
Comment
Question by:Vasantreddy
1 Comment
 
LVL 5

Accepted Solution

by:
mfsamuel earned 2000 total points
ID: 20321851
You will need to create a new table to store the user preferences.  It appears that you are planning on haveing each user/group combination have a unique sort order.

Without knowing specific database leve details, create a table with columns
preference_id (pk)
group_id
user_id
product_id
order

When you are generating the page to display the data you innner/left join against the preferences table and order by the the order column.

The mechanics of the sort can happen at the database layer, your application will just need to update the table to preserve the structure.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question