Loading ...
Sorry, an error occurred while loading the content.

multicolumn order() not working as expected when column has alpha and numeric

Expand Messages
  • bitflipperjoel
    This code: var db = TAFFY([ {col1: a ,col2: c }, {col1: a ,col2: b }, {col1: a ,col2: a }, {col1: 1 ,col2: a }, {col1: 1 ,col2: b },
    Message 1 of 1 , Sep 12, 2012
    • 0 Attachment
      This code:
      var db = TAFFY([
      {col1:'a',col2:'c'},
      {col1:'a',col2:'b'},
      {col1:'a',col2:'a'},
      {col1:'1',col2:'a'},
      {col1:'1',col2:'b'},
      {col1:'1',col2:'c'}
      ]);

      db().order('col1 logical, col2').each(function(rec,num) {
      console.log(rec.col1,rec.col2);
      });
      Returns:
      a a
      1 a
      a b
      1 b
      a c
      1 c

      I would expect ordering by col1, then by col2 would result in the first columns data being all together like:
      a a
      a b
      a c
      1 a
      1 b
      1 c
      (or 1's before a's)

      It does seem to work if col1 is always characters or always numbers but with mixed characters and numbers it's not what I expect.  How would I achieve my result?

      Tx!


    Your message has been successfully submitted and would be delivered to recipients shortly.