Sort Numbers as Numeric

Bastiaan Olij bastiaan at muxworks.com.au
Sat Jun 12 11:33:36 UTC 2021


Hey Michael,

Owh the A/B in there makes it a lot harder.
We did this for codes in our system and either when retrieving the data, 
or after the list is build, we add a column that parses the data, 
extract the numeric part, add some zeroes and put the string back together.
So the new column would look like
A000001
000002
000001
B000002
000020
000012

And sorting by that column would sort it properly.

You can use regex to extract the numeric part, just use something like
calculate lvPos as rxpos(lvList.C1, '[0-9]+',kFalse,kFalse,lvLen)
And then use lvPos and lvLen to extract the numeric part and use jst to 
prefix the right number of zeroes, and concatenate the string back together.

Cheers,

Bas

On 6/12/2021 9:18 PM, Michael Mantkowski wrote:

> I have a list of values in a character field like this.
>
> A1
> 2
> 1
> B2
> 20
> 12
>
> It Sorts like this.
>
> 1
> 12
> 2
> 20
> A1
> B2
>
> I want it to sort like this.
>
> 1
> 2
> 12
> 20
> A1
> B2
>
> Seems like I should know how to do this, but it is not coming to me this morning...
>
> Any help?
>
> Thanks!!
>
> *********************************************************************
> Michael Mantkowski
> ClienTrax Software
> 1-614-875-2245
> *********************************************************************
>
>   
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

-- 
Kindest Regards,

Bastiaan Olij
bastiaan at muxworks.com.au
+61-432144833



More information about the omnisdev-en mailing list