Item14854: Unexpected sorting of numerals where numbers are extracted using pattern parameter

pencil
Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release:
Applies To: Extension
Component: FilterPlugin
Branches:
Reported By: LynnwoodBrown
Waiting For:
Last Change By: LynnwoodBrown
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
 

ItemTemplate edit

Summary Unexpected sorting of numerals where numbers are extracted using pattern parameter
ReportedBy LynnwoodBrown
Codebase 2.1.6
SVN Range
AppliesTo Extension
Component FilterPlugin
Priority Normal
CurrentState No Action Required
WaitingFor
Checkins
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release02x01Checkins
Release02x00Checkins
Release01x01Checkins
Topic revision: r3 - 22 Oct 2019, LynnwoodBrown
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy