views:

21

answers:

1

I have a column that contains address "line 2" type values. this column can contain values like #431, UNIT 203, and APT. C and of course it can contain blank (or empty string) values also. i need an answer to two questions:

  1. How would you expect a mixed values like this to be sorted (i.e. blank or pound signs on top when ascending)?
  2. How would i pull this off with a custom parser?

currently with the default parser (i'm assuming the string parser), it is ordering the values pound signs, blanks, and then a-z values when in ascending order. i would think that it would blanks, pound signs, and then a-z values.

A: 

To answer #1, my expectation would be that those values would appear in this order:

"UNIT 203"
"#431"
"APT. C"

You can probably do this by trimming all but the number away if a number exists in the string, and just removing some known prefixes and trimming if there isn't a number. Whatever you do won't be perfect, and that's something you'll just have to accept/explain.

Stuart Branham
the customer wanted a "dictionary sort" where punctuation and whitespace is ignored and the remaining string is sorted as a string. I used a custom parser that isn't auto-detected and returns s.replace(/(\.|#|\s|-| )/g, '') for the format function. i'm marking your answer is the solution cause it's just as good as what i ended up using.
gabe