# Alteryx Designer

SOLVED

## Sort Multiple Columns

Highlighted
Alteryx Certified Partner

Hi,

I'm working on some sorting requirement.

Data looks like this:

 Column1 Column2 Column3 A a 11 A b 12 B y 13 B z 14 A z 15 A y 16 B a 17 B b 18 C z 19 C y 20 C b 21 C a 22

I want to custom sort left two columns such that result would be:

 Column1 Column2 Column3 A b 12 A y 16 A z 15 A a 11 B a 17 B y 13 B z 14 B b 18 C a 22 C b 21 C z 19 C y 20

---

rahul

Highlighted
ACE Emeritus

For sorting that requires anything other than a simple ordering, I would generate a "SortOrder" variable, and calculate it based on whatever rules I had in mind; then just order based on that variable.  It appears that you've got a pretty wild ordering in mind; if you can explain the rules you used to come up with that order, we might be able to assist with expressions to calculate it.

Hope that helps!

John

Highlighted
Alteryx Certified Partner

Thanks John.

I had to sort based on two text columns.

I came with with my solution, sharing here:

first i sorted A, B, C by assigning them 100, 200 and 300

next i assigned a, b, y, z those values such as 1, 2, 3, and 4 based on my custom sort logic.

Finally i added 100, 200, 300 with 1, 2, 3, 4 to get final numbers as 101, 102... and so on.

my last step involved sorting on the combined number.

thanks for ur concern,...

Labels