Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release:
The sort parameter with option "num" does not work as expected from the docs when the numbers are extracted using the pattern parameter.
Here's a simple example that works fine:
%FORMATLIST{"0,2,7,3,1"
split=","
format="$1"
separator=","
sort="num"
}%
...which produces: 0,1,2,3,7
However, here's another simple example, but where the numbers are extracted via the pattern parameter:
%FORMATLIST{"ssgdb~0,a2gowe~2,trsgwed~7,14fwet~3,h23wetd~1"
split=","
pattern=".*?~(.*)"
format="$1"
separator=","
sort="num"
}%
...which produces: 0,2,7,3,1
--
LynnwoodBrown - 21 Oct 2019
The list items are not numerical, nor does the pattern parameter play a role before sorting it. The pattern parameter is applied just before formatting the items. Try this instead:
%FORMATLIST{
"%FORMATLIST{"ssgdb~0,a2gowe~2,trsgwed~7,14fwet~3,h23wetd~1" pattern="(.*)~(.*)" format="$2=$1" separator=","}%"
pattern="(\d+)=(.*)"
format="$1"
separator=","
sort="num"
}%
--
MichaelDaum - 22 Oct 2019
Thanks for the clarification. I guess I was thrown off by the phrase in the doc for the sort parameter that says "order of the formatted items" - which I interpreted to mean the the sort was applied
after the formatting and consequently that the type of sort referred to the formatted result. If I understand you correctly now, the sorting is actually done on the original list items, so the initial characters of each items is what really determines the behavior of the sort.
Perhaps it would be worthwhile to to revise the documentation for the sort parameter to read:
- sort="on,off,alpha,num,nocase" order applied to items in list prior to formatting (default "off")
--
LynnwoodBrown - 22 Oct 2019