My problem is I am trying to sort this lists within a dictionary where I am using the dictionary name as the field name and the lists as the data rows. I have a feeling I am using the wrong approach (should this be a tuple or a dataframe or what?)
I have tried using sorted() but can't get past only sorting by the key (e.g. name, score1, score2). I want to maintain the key order but rearrange the values while keeping their relationship across keys.
This is a sample dataset that I want to sort by score1 (or score2):
scores = {'name': ['joe', 'pete', 'betsy', 'susan', 'pat'], 'score1': [99, 90, 84, 65, 100], 'score2': [85, 91, 90, 55, 98]}
After sorting for score1, I would like to see:
pat, joe, pete, betsy, susan
After sorting for score1, I would like to see:
pat, pete, betsy, joe, susan