Re: sort constants confusing

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...

I could not work out why there were 4 sort options. It reads, at best, like you have to use ASCENDING for sort() and NORMAL_ORDER for custom_sort().

As soon as I looked at the source, the penny dropped instantly.

The constants NORMAL_ORDER and REVERSE_ORDER are just aliases for ASCENDING and DESCENDING respectively, and behave identically.

DerekParnell said...

Agreed. Why they exist is a mystery. In any case I would have expected normal/abnormal or forward/reverse pairs instead.

I traced the history of it.

ASCENDING/DESCENDING was CChris's idea - before that the code only sorted in ascending - http://scm.openeuphoria.org/hg/euphoria/annotate/d63e0d759325/include/std/sort.e#16

But he didn't invent the term - the initial commit for the file has the term 'ascending' in it - http://scm.openeuphoria.org/hg/euphoria/annotate/076e4e3c0f12/include/std/sort.e

I checked my copy of sort.e from RDS Eu 2.3 and it uses the same term. So ASCENDING goes back to RobCraig.

Derek was the one who added the custom_sort() aliases - and the misleading comments to go with it - http://scm.openeuphoria.org/hg/euphoria/annotate/1debb13c40cf/include/std/sort.e#24

Derek, why did you add a normal/reverse pair instead of your expected forward/reverse pair ?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu