2 way sorting a table with Javascript..

Discussion in 'JavaScript' started by toughguy, Mar 25, 2007.

  1. #1
    Hi Friends,
    I got efficient solutions on DP from fellow DPers couple of time.. U guys ROCK !!!

    I would like to know if we can sort a table 2 way using Javascript.
    For example, if we have a table with information of hotels and there are 2 (numeric) columns Price and Rating. How to sort the table based on Price first and then on Rating.. i.e., It is like if prices of two hotels are same, they need to sorted as per their rating..

    Hope my question is clear.

    Eagerly waiting for ur replies..

    Regards,
     
    toughguy, Mar 25, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    I'm doing that with XSLT transformations on client.
    You can have 1, 2, 3... or n sorting fields, aplying sequentially. You only need to ad as many <xsl:sort> expressions inside your <xsl:for-each> loop.

    But IMO this XSLT transformation method is only por advanced AJAX users. Maybe other DP users know some javascript libraries to do that
    .
     
    ajsa52, Mar 26, 2007 IP
  3. toughguy

    toughguy Well-Known Member

    Messages:
    846
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    118
    #3
    Hi,
    Thanks for the suggestion.. But i want to see if it can be done using simple javascript.

    Regards,
     
    toughguy, Mar 26, 2007 IP
  4. Dempsey

    Dempsey Well-Known Member

    Messages:
    203
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    163