I have a list of lists in Python that essentially represent a table. I know I should have used a pandas dataframe to accomplish this, but hindsight is 20/20. I digress...below is an example list of what I'm talking about.
The overarching list variable is comprised of these nested lists:
['Store number', 2, 3, 4, 1, 5]
['Variable 1', 82, 99, 44, 32, 65]
['String 1', 'cat', 'dog', 'lizard', 'alligator', 'crocodile']
In the current state, each index of each nested list corresponds to the same row in the table. So for store number 2, variable 1 is 82 and string 1 is cat. Say I want to sort each list to where these relationships are maintained, but we sort by ascending store number. The final lists would look like:
['Store number', 1, 2, 3, 4, 5]
['Variable 1', 32, 82, 99, 44, 65]
['String 1', 'alligator', 'cat', 'dog', 'lizard', 'crocodile']
How could I accomplish this using my current data structures?
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.