why need asc and desc sort routines

why need asc and desc sort routines

fbasfbas Posts: 1,094Questions: 4Answers: 0
edited May 2011 in General
I was wondering why when adding sort routines you need to provide ascending and descending routines. I would think that something like ascendsort(x,y) implicitly could be reversed by swapping the parameter order, i.e. descendsort(x,y) is equivalent to ascendsort(y,x). Is there something I'm missing?

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    It's a good question :-). There are two reasons why it is the way it is at the moment:

    1. If there were only one method it would need to be known to the author that all sorting methods should be written as asc (or desc) which might lead to confusion. In addition to this you would have the overhead of 'reverse' on one of them and not the other.

    2. Whe. I original wrote the sorting. Implementation I figured it might be useful to be able to sort differently when desc from asc. Obviously this is of limited use, but it is possible. It's only a few extra lines of code so I though that it would be fair enough for the extra flexibility.

    This isn't something g that can be changed in the 1.x series of DataTables - but it will be soething I consider carefully for DataTables 2.

    Regards,
    Allan
This discussion has been closed.