Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

srp_sort_array DR with decimal values

ar = 12.12:@vm:14.14:@vm:13.10
ar = srp_sort_array(ar,'DR1',0,@fm,@vm)

returns : 14.14:@vm:12.12:@vm:13.1
This is not the correct order.
13.0 is changed in 13.1

Regards Ed


  • Instead of "DR" try "DN". We added this to support true numerical (versus right-aligned alphanumeric) sorting. This won't resolve the stripping of the "0" in your 13.10 value, so I'll ask Kevin to investigate and comment.

  • We misread the "N" option for sort-method in the documentation. We just thought the options were just like in OI "L" or "R". Sorry about that....
  • This works for me in 2.2.2, but you will still lose the trailing 0 unless you quote the numbers. OI is the one turning 3.10 into 3.1 before the array is passed into the routine. If you opt for the 'N' option, you will always lose insignificant 0's because SRP_Sort_Array converts them into actual decimal numbers for mathematically accurate sorting.
  • Because the variable AR was filled in code the insignificant 0's were stripped by OI.
    We tried this
    ar = "12.12#14.14#13.10"
    ar<2> = ar<1>
    convert '#' to @vm in ar
    ar = srp_sort_array(ar,'DN1',0,@fm,@vm)
    We got the variable AR back with the insignificant 0
    At the end everything works fine.

    Sorry for wasting your time...
    Regards Ed
Sign In or Register to comment.