Multiple Sorting of Columns

Results 1 to 2 of 2

Thread: Multiple Sorting of Columns

  1. #1
    Join Date
    Dec 1969

    Default Multiple Sorting of Columns

    I have a page which displays the records in columns.<BR>I am able to sort each column by ASC and DESC through link in the column heading at the moment.<BR><BR>What I want to do is to be able to sort the records by one column and then re-sort the sorted results by clicking another column but still remembering the previous sort options.<BR><BR>How do I go about doing this? What do I need to do?

  2. #2
    Join Date
    Dec 1969

    Default Interesting...

    Not too tough, but kind of "detail oriented."<BR><BR>You have to somehow *remember* the last sort done (you must be partially doing that, to handle the ASC/DESC stuff) and then append that to the end of the new sort.<BR><BR>So suppose that the last sort had you doing<BR>.... ORDER BY FirstName ASC<BR><BR>And now the user clicks on LastName. You have to do<BR>.... ORDER BY LastName ASC, FirstName ASC<BR><BR>Now, that&#039;s not *too* tricky to do. But what do you do when the user clicks on the LastName column again, to sort that in reverse order? You certainly do not want to have<BR>.... ORDER BY LastName DESC, LastName ASC<BR><BR>So you have to remember the last sort on a different column separately from the last sort, period.<BR><BR>And if you want to handle 3 and 4 columns this way, then you have to get even a bit more clever. <BR><BR>But like I said...this is just details. The concept isn&#039;t hard. You just have to figure out how and where to store what that will drive the multiple ORDER BYs properly.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts