I have this particular dataset:
{
"Player 1": [0, 1, 3, 5, 7, 0]
"Player 2": [3, 2, 4, 7, 6, 1]
"Player 3": [1, 3, 5, 4, 5, 1]
}
and need this output based on low to high (element 0 has re-ordered the list):
{
"Player 1": [0, 1, 3, 5, 7, 0]
"Player 3": [1, 3, 5, 4, 5, 1]
"Player 2": [3, 2, 4, 7, 6, 1]
}
or this output based on high to low (element 0 has re-ordered the list):
{
"Player 2": [3, 2, 4, 7, 6, 1]
"Player 3": [1, 3, 5, 4, 5, 1]
"Player 1": [0, 1, 3, 5, 7, 0]
}
The output here shows a reordering of the keys/values, because the value in element 0 in each list has been sorted by lowest to highest. I have been thinking of how to do this, and although my current data model doesn't require a key/value pair for each "entry", it makes the most sense.
I am rather unsure of how to go about this as efficiently as possible, such as only grabbing element 0, creating a temp list, reordering the temp list and re-mapping the dict entries into this order.
Or, searching through the list and reordering either by highest to lowest, lowest to highest, and popping each element off as it becomes either the lowest available or highest available, and then starting back at the top.
What is the most efficient way to achieve this?