Difference between order and sort

Difference between order and sort

highflyinghighflying Posts: 9Questions: 5Answers: 0

Seems like order and sort are used interchangeably. Can someone describe to me the difference between the two? The sort() page doesn't do a good job in showing examples of one vs the other.

Thanks in advance.

This question has accepted answers - jump to:


  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394
    Answer ✓

    There is no difference.
    The Examples index actually says "Default ordering (sorting)".

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin
    Answer ✓

    Actually there is a difference between sort() and order(). To try and be consistent with naming:

    • order refers to ordering the data in the DataTable (and then displaying that to the end user)
    • sort (specifically sort()) refers to sorting the data in an API's result set. e.g you can do table.column(0).data().sort() to get an "array" of data from the first column which is sorted in the array, without effecting the table's ordering. Think of it like Array.prototype.sort().

    I've tried to be consistent in the documentation to match the above, but before 1.10, the two terms were used interchangeably which certainly leads to confusion (and the odd mistake from me!).


  • highflyinghighflying Posts: 9Questions: 5Answers: 0

    Thanks Allan that helps a lot!

This discussion has been closed.