alphanumeric sort

Claus Guttesen kometen at gmail.com
Wed May 11 15:54:12 EDT 2011


Hi.

I have a function that performs a numeric sort (ascending) as
described at http://siculars.posterous.com/using-riaks-mapreduce-for-sorting.
But how to perform an alphanumeric sort?

I'm using the code found in the link above:

var reduceSort = function (v, args) {
  return v.sort (function(a, b) { return a['key'] - b['key'] });
};

I'm writing a small app using express, riakjs and riak to keep track
of crosscountry-races for kids, and would like to sort by name like:

var reduceSort = function (v, args) {
  return v.sort (function(a, b) { return a['fname'] - b['fname'] });
};

Hopefully I'm not asking dumb questions. :-)

-- 
regards
Claus

When lenity and cruelty play for a kingdom,
the gentler gamester is the soonest winner.

Shakespeare

twitter.com/kometen




More information about the riak-users mailing list