How do I sort data by numbers?

How do I sort data by numbers?

conciseconcise Posts: 13Questions: 5Answers: 0
edited May 2015 in Free community support

What I mean is this:

My table has data sorted so that the first column has numbered data, such as 5,9,14 etc. All the rest of the columns contain simple text.

Currently datatables sorts the data perfectly from column 1 by numbers but it does so from low to high.

How can I make the opposite happen, i.e. sort the numbered data in column 1 from high to low?

Thanks!

Answers

  • conciseconcise Posts: 13Questions: 5Answers: 0

    I'm pretty sure this is required:

    '$('#example').dataTable( { "columns": [ null, { "orderSequence": [ "asc" ] }, { "orderSequence": [ "desc", "asc", "asc" ] }, { "orderSequence": [ "desc" ] }, null ]} );

  • conciseconcise Posts: 13Questions: 5Answers: 0

    OK i fixed it...

    I added this and it all worked:

                    $(document).ready(function() {
                      var oTable = $('#example').dataTable();
                      oTable.fnSort( [ [0,'desc'] ] );
                    } );
    
This discussion has been closed.