My goal is to sort the variables using the second column numbers in ascending order.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Variables to sort:

v1:=12

v2:=2

v3:=7

v4:=4

v5:=18

Values used for sorting. id1 represents v1, id2 represents v2 and so on.

id1:=500

id2:=200

id3:=1000

id4:=700

id5:=400

200->400->500->700->1000

so...

id2 -> id5 -> id1 -> id4 ->id3

so...

v2 -> v5 -> v1 -> v4 -> v3

Expected result:

c1:= v2

c2:= v5

c3:= v1

c4:= v4

c5:= v3

As you can see, id2 is the smallest with 200 so its counterpart v2 goes to c1, the first on the list and so on. How to sort this?