Skip to main content
Solved

Alphanumeric sorting in ListRangeExtractor

  • November 20, 2015
  • 5 replies
  • 34 views

I have list attribute list{}.lbl, where lbl has these (alphanumeric) values 3A,5,7,9,11,13,15. I need the smallest (3A) and largest (15) value. ListRangeExtractor give Resulting Minimum Attribute 3A and Resulting Maximum Attribute 7. I suppose ListRangeExtractor and I don't fully agree on sorting order of alphanumerical values, it seems like it prefer to sort it either numerical (3...15 works fine) or alphabetical. Does any expert user have a suggestion or workaround to solve this list issue? Thanks!

 

Best answer by takashi

Hi,

 

 

The ListRangeExtractor cannot be used in this case.

 

"If some values are numeric and some are not, the minimum and maximum values extracted may not be useful." -- Help of the ListRangeExtractor

 

 

Expanding @markireland's suggestion, if the resulting minimum value should be "3A", this workflow is available.

 

  1. ListCopier: Copy the original list "list{}" to "tmp{}".
  2. ListRenamer: Rename "tmp{}.lbl" to "list{}.xxx".
  3. ListStringReplacer (FME Store): Remove every non-digit from every element of "list{}.xxx".
  4. ListSorter: Sort "list{}.xxx" by numeric ascending.
  5. LIstIndexer: Demote the first element of "list{}.lbl" (List Index: 0), adding a prefix "min_".
  6. ListIndexer_2: Demote the last element of "list{}.lbl" (List Index: -1), adding a prefix "max_".
You can then find two attributes - "min_lbl" storing "3A" and "max_lbl" storing "15".

 

 

However, if the "list{}.lbl" has been created in the preceding data flow in the workspace, I would consider firstly whether @francis_m and @gio's suggestion (sort before list building) can be applied.

 

Takashi
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

francis_m
Contributor
Forum|alt.badge.img+7
  • Contributor
  • November 20, 2015

Hi!

Before having the list build, split your "lbl" (like lbl_num and lbl_alpha) and then sort list by lbl_num. Like that you will have 3 and 15 as range.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • November 20, 2015
it does a ordinal ordering, not alphabetic nor numerical, when the characters are alfnumeric.

 

Wich places 15 before 7. This is normal behaviour.

 

 

Before building the list and consequentially before the listrange extractor ,i would use a sorter and sort on both components. If they are not available separate, you must first create sorting fields by splitting them.

 

 

If not possible before building the list, you still must split the listattribute, wich forces u to explode the list...

 

So i would definitely do it before listbuilding iff poss.

 


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • November 20, 2015
Would "3" be OK instead of "3A"? If so, I see a ListStringReplacer in the FME Store that you could use to remove the non-numeric characters first. Or at least that could be a first step to find the min/max numbers before checking for suffixes.

 


takashi
Influencer
  • Best Answer
  • November 21, 2015
Hi,

 

 

The ListRangeExtractor cannot be used in this case.

 

"If some values are numeric and some are not, the minimum and maximum values extracted may not be useful." -- Help of the ListRangeExtractor

 

 

Expanding @markireland's suggestion, if the resulting minimum value should be "3A", this workflow is available.

 

  1. ListCopier: Copy the original list "list{}" to "tmp{}".
  2. ListRenamer: Rename "tmp{}.lbl" to "list{}.xxx".
  3. ListStringReplacer (FME Store): Remove every non-digit from every element of "list{}.xxx".
  4. ListSorter: Sort "list{}.xxx" by numeric ascending.
  5. LIstIndexer: Demote the first element of "list{}.lbl" (List Index: 0), adding a prefix "min_".
  6. ListIndexer_2: Demote the last element of "list{}.lbl" (List Index: -1), adding a prefix "max_".
You can then find two attributes - "min_lbl" storing "3A" and "max_lbl" storing "15".

 

 

However, if the "list{}.lbl" has been created in the preceding data flow in the workspace, I would consider firstly whether @francis_m and @gio's suggestion (sort before list building) can be applied.

 

Takashi

  • Author
  • November 23, 2015

Thanks for pointing out for me that the ListRangeExtractor is either numerical OR alphabetical, not both in combination.

As my need was to maintain the alphanumeric structure I ended up with much of Takashi's structure. The numeric and alphabetical part of lbl was available, so I created a custom transformer to do the trick, with a ListSorter on the numeric part, and then two ListIndexers to extract the correct max and min values. Thanks to the rest of you for the suggestions to look for the original numerical and character parts of "lbl".


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings