Solved

Updating Sort Order

Posted on 2007-11-19
3
232 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
3 Comments
 
LVL 5

Accepted Solution

by:
mfsamuel earned 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This video teaches viewers about errors in exception handling.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

832 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