flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 240: Sort 2 lists together
Idiom # 240: Sort 2 lists together
See
programming-idioms.org
:
Code
sort list b based on the sorting of list a
s := a.zip b x,y->(x,y) .sort (x,y -> x.values.0 <= y.values.0) a := s.map v->v.values.0 b := s.map v->v.values.1
What are effects?
Running Example
ex240 is a := [ "siebenundvierzig", "elf", "null", "acht", "fünfzehn" ] b := [ "47", "11", "0", "8", "15" ] s := a.zip b x,y->(x,y) .sort (a,b -> a.values.0 <= b.values.0) a := s.map v->v.values.0 b := s.map v->v.values.1 say a say b # NYI: With more syntax sugar for tuples, this should be: # # s := a.zip b x,y->(x,y) # .sort_by x->x.0 # a := s.map v->v.0 # b := s.map v->v.1
What are effects?
next: NYI: Idiom # 241: Yield priority to other threads