Question

Sorter and ListSorter to sort multiple attributes with numeric values

  • 20 November 2019
  • 16 replies
  • 55 views

Badge +1

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

Userlevel 1
Badge +10

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.

Badge +1

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.

Userlevel 4

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

 

Userlevel 1
Badge +10

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!

Userlevel 1
Badge +10

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

Badge +1

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!

Badge +1

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
Userlevel 1
Badge +21

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

Badge +1

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

Thanks for taking the time ebygomm!

Userlevel 1
Badge +21

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

Badge +1

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?

Userlevel 1
Badge +10

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.

Userlevel 1
Badge +10

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.

Userlevel 1
Badge +10

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.

Badge +1

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.

Badge +1

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!

Reply