Skip to main content
Question

Sorter and ListSorter to sort multiple attributes with numeric values

  • November 20, 2019
  • 16 replies
  • 482 views

benadei
Contributor
Forum|alt.badge.img+4

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!

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, 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.

16 replies

nampreetatsafe
Safer
Forum|alt.badge.img+13
  • Safer
  • 383 replies
  • November 20, 2019

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
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 11 replies
  • 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
  • 8394 replies
  • 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
  • Safer
  • 383 replies
  • 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

 

Appreciate the correction @david_r!


nampreetatsafe
Safer
Forum|alt.badge.img+13
  • Safer
  • 383 replies
  • November 22, 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.

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
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 11 replies
  • November 22, 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

 

Thanks for taking the time david_r!


benadei
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 11 replies
  • 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+44
  • Influencer
  • 3427 replies
  • 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

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


benadei
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 11 replies
  • November 22, 2019

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+44
  • Influencer
  • 3427 replies
  • November 22, 2019

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
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 11 replies
  • November 22, 2019

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
  • Safer
  • 383 replies
  • November 22, 2019

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
  • Safer
  • 383 replies
  • November 22, 2019

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
  • Safer
  • 383 replies
  • November 22, 2019

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
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 11 replies
  • November 22, 2019

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
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 11 replies
  • November 26, 2019

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!