Re: Natural sort comparison

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

I have been thinking of this stuff as Mike Sort (with obvious inference to some competitive sorting algorithm). Since I didn't invent it I wait for input.


Sorting API must consist of:

  • data: integer|atom|string|object
  • stability: TRUE|FALSE
  • direction: UP|DN
  • order: arithmetic|natural|custom
  • column: 0|1|2|...
  • index sorting

The API question is:

  • a universal sort with five (or more) arguments
  • sort with the most "popular" arguments
  • lots of specialized sort routines with minimal argument lists

This is a teaching opportunity to show me how to design a library. Time to hear from Pete about what he expects in a sorting library.


The Natural Order algorithm is by Andy Serpa. "Natural Order" is sometimes called "Lexical Order" which is the alternative to "arithmetic order." The existing algo does not do everything:

The algorithm only takes into account "unbroken" integers within the 
character strings  
it makes no allowance for decimal points (although it 
will still work correctly as long as there are an equal number of digits 
to the right of the decimal point in each number being compared). 

I have not thought about unicode and case sensitivity (monocasting; seems like an ugly word) variations in a custom sort.

In the pastey I left out a second sorting algo that is optimized for objects that are only string sequences--making it about twice as fast. In the original he also uses custom_sort(ID) as a way of executing the sorting.

Since using routine_id is expensive, is it worth writing the sorting comparison directly into the sorting algorithm?

_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu