Skip to main content
Question

Sorter and ListSorter to sort multiple attributes with numeric values


benadei
Participant
Forum|alt.badge.img+3

I have been trying to use transformers Sorter and ListSorter to sort multiple attributes with numeric values without success. Any help will be deeply appreciated. Thanks!

16 replies

nampreetatsafe
Safer
Forum|alt.badge.img+13

Welcome to the FME Community @benadei! It will be really helpful if you explain what you have tried so far, what errors/results you are getting. Screenshots are always helpful, or providing your workspace and sample data is even better if possible. This guide for New FME Community users provides useful tips on how to best engage with the FME Community.

To your question, the Sorter should allow you to add multiple attributes by clicking on the + button in the Sorter's parameters dialog:

If you are working with list attributes, you might have to string together multiple ListSorter transformers one after another? I hope this helps.


benadei
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • November 20, 2019

Hi nampreetatsafe! Thanks for your response! I added three attributes out of the 52 attributes I need sorted in ascending order, but only the first attribute or column was sorted. The remaining attributes added were not sorted. Basically, I am trying to sort multiple columns as in Microsoft Excel, column by column using FME Desktop. Please review the attached images.


david_r
Celebrity
  • November 21, 2019

Note that the ListSorter does not currently support sorting by multiple attributes, even if you chain one ListSorter after one another. This is a known limitation, so please consider voting for this idea:

https://knowledge.safe.com/content/idea/72018/listsorter-to-support-multiple-sort-by-criteria.html

 


nampreetatsafe
Safer
Forum|alt.badge.img+13
david_r wrote:

Note that the ListSorter does not currently support sorting by multiple attributes, even if you chain one ListSorter after one another. This is a known limitation, so please consider voting for this idea:

https://knowledge.safe.com/content/idea/72018/listsorter-to-support-multiple-sort-by-criteria.html

 

Appreciate the correction @david_r!


nampreetatsafe
Safer
Forum|alt.badge.img+13
benadei wrote:

Hi nampreetatsafe! Thanks for your response! I added three attributes out of the 52 attributes I need sorted in ascending order, but only the first attribute or column was sorted. The remaining attributes added were not sorted. Basically, I am trying to sort multiple columns as in Microsoft Excel, column by column using FME Desktop. Please review the attached images.

Sorry @benadei, could you possibly illustrate what your desired result is? I I could be misunderstanding your intended results.

In my experience, sorting multiple attributes using the Sorter works like so... If you have:

346249228157366348146227

 

Then if you sort it by the first, second, and third columns in ascending order, respectively, you would get the following:

146157227228249346348366

 

I hope that makes sense. I've attached a quick workspace template that illustrates this idea: sortmultiple.fmwt


benadei
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • November 22, 2019
david_r wrote:

Note that the ListSorter does not currently support sorting by multiple attributes, even if you chain one ListSorter after one another. This is a known limitation, so please consider voting for this idea:

https://knowledge.safe.com/content/idea/72018/listsorter-to-support-multiple-sort-by-criteria.html

 

Thanks for taking the time david_r!


benadei
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • November 22, 2019

Hi @nampreetatsafe! Thanks for taking the time to respond again. Sorry if I have not been very clear in the results I am looking for, but is it possible to sort all columns or attributes independently in ascending order for example to get the result below instead?

1 2 6

 

1 2 6

 

2 4 6

 

2 4 7

 

2 4 7

 

3 4 8

 

3 5 8

 

3 6 9

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • November 22, 2019
benadei wrote:

Hi @nampreetatsafe! Thanks for taking the time to respond again. Sorry if I have not been very clear in the results I am looking for, but is it possible to sort all columns or attributes independently in ascending order for example to get the result below instead?

1 2 6

 

1 2 6

 

2 4 6

 

2 4 7

 

2 4 7

 

3 4 8

 

3 5 8

 

3 6 9

It's possible but not with a single sorter, as the sorter will sort features, not attributes independently


benadei
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • November 22, 2019
ebygomm wrote:

It's possible but not with a single sorter, as the sorter will sort features, not attributes independently

Thanks for taking the time ebygomm!


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • November 22, 2019
benadei wrote:

Thanks for taking the time david_r!

If you have 52 different columns to sort independently I think you'll need some sort of looping custom transformer or some python


benadei
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • November 22, 2019
ebygomm wrote:

If you have 52 different columns to sort independently I think you'll need some sort of looping custom transformer or some python

Ok, thanks @ebygomm! Is there a way of splitting the attributes and sorting each of the individual attributes as separate features?


nampreetatsafe
Safer
Forum|alt.badge.img+13

Here's a reworked workspace demonstrating one possible approach using only 3 attributes: sortmeindividually.fmwt. I used an AttributeKeeper to isolate an attribute, ran it through the Sorter, then through a Counter to help with rejoining the attributes back together after they are sorted.

As @ebygomm mentioned earlier, you may want to consider using looping custom transformer or python to help process the 52 attributes. But I'm hoping this helps you with the general concept.


nampreetatsafe
Safer
Forum|alt.badge.img+13
benadei wrote:

Thanks for taking the time ebygomm!

Here's a reworked workspace demonstrating one possible approach using only 3 attributes: sortmeindividually.fmwt I used an AttributeKeeper to isolate an attribute, ran it through the Sorter, then through a Counter to help with rejoining the attributes back together after they are sorted.

As @ebygomm mentioned earlier, you may want to consider using looping custom transformer or python to help process the 52 attributes. But I'm hoping this helps you with the general concept.


nampreetatsafe
Safer
Forum|alt.badge.img+13
benadei wrote:

Ok, thanks @ebygomm! Is there a way of splitting the attributes and sorting each of the individual attributes as separate features?

I attempted it in my last answer here. Let me know if that makes sense.


benadei
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • November 22, 2019
nampreetatsafe wrote:

Here's a reworked workspace demonstrating one possible approach using only 3 attributes: sortmeindividually.fmwt. I used an AttributeKeeper to isolate an attribute, ran it through the Sorter, then through a Counter to help with rejoining the attributes back together after they are sorted.

As @ebygomm mentioned earlier, you may want to consider using looping custom transformer or python to help process the 52 attributes. But I'm hoping this helps you with the general concept.

Thank you so much! I will try your newest suggestion. Have a good weekend.


benadei
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • November 26, 2019
nampreetatsafe wrote:

Here's a reworked workspace demonstrating one possible approach using only 3 attributes: sortmeindividually.fmwt. I used an AttributeKeeper to isolate an attribute, ran it through the Sorter, then through a Counter to help with rejoining the attributes back together after they are sorted.

As @ebygomm mentioned earlier, you may want to consider using looping custom transformer or python to help process the 52 attributes. But I'm hoping this helps you with the general concept.

Thank you so much for taking the time to help. Much appreciation!


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