Foren Foren

Zurück

Sorting Variables To Find Top 2

Umschalten
Sorting Variables To Find Top 2
Antwort
16.05.23 15:12
I'm looking for the best way to sort five variables largest to smallest while retaining their identification. 

In my project, I'm accumulating scores in five categories, and need to know what the top two categories are based on the scores. I'm sure I could create a bunch of conditional statements to work it out but I'm thining there's an easier way.

Thanks!
0 (0 Stimmen)

RE: Sorting Variables To Find Top 2
Antwort
16.05.23 16:28 als Antwort auf Bryan Lambert.
Hi Bryan,
Great question! Yes, it's possible, and creating a bunch of conditions would be a pain. Here's how you can sort a list of values, and then work backwards using a second list of names to figure out the order.
Video: https://share.smartbuilder.com/public/support/sorting-values.mp4
Sample file: https://share.smartbuilder.com/public/support/sorting-values2.sb4

Since we spoke last, we found out there's already a block that sort of handles this. Check out page 2 of file above. It requires formatting the data in a particular way - a List, and each entry in that List is a Map with two entries - name and count (those names are arbitrary, they could be category and score). With this method the logic is much simpler (one action block to sort), but the overhead of putting it in the right format and extracting the data that you need is higher.

List of Maps video: https://share.smartbuilder.com/public/support/sorting-values-part2.mp4

Let us know if you have any questions!
0 (0 Stimmen)