0

I have a set of lists embedded within a list

Id like to sort the first list alphabetically and for the other lists to then be arranged in the same order.

Current:

[['Doug','Jane','Bob'],[30,20,50],[80,100,50]]

Desired output: Output

[['Bob','Doug','Jane'],[50,30,20],[50,80,100]]
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
user4891693
  • 35
  • 1
  • 2
  • 5
  • What is the second sublist sorted descending while the third one is sorted ascending? – Tim Biegeleisen May 25 '22 at 02:22
  • @TimBiegeleisen coincidence; they're both sorted according to the first list – Nick May 25 '22 at 02:23
  • @TimBiegeleisen the idea is that both lists of numbers are *permuted* the same way as the list of strings was permuted, in order to sort the list of strings. The values `20` and `100` are associated with `'Jane'`, so they go to the ends of their respective lists, just like `'Jane'` does. – Karl Knechtel May 25 '22 at 02:23
  • OP: it would normally be better to collect related information into structures, rather than having parallel lists. But if you must have parallel lists for some other reason, then knowing the term `parallel list` makes it much easier to look these things up yourself, [as is expected](https://meta.stackoverflow.com/questions/261592). Hence the linked duplicate. – Karl Knechtel May 25 '22 at 02:25

0 Answers0