Suppose I have a list named L and two attribute dictionaries named arr1
and arr2
, whose keys are the elements of the list L
. Now I want to sort L
in the following manner.
L
should be sorted in ascending order by virtue of the attribute values present inarr1
.- If two elements
i
andj
ofL
have same attributearr1
, i,e, ifarr1[i]
andarr[j]
are equal, then we should look for the attribute values inarr2
.
To give an example, suppose
L=[0,1,2,3,4,5,6]
arr1={0:30,1:15,2:15,3:20,4:23,5:20,6:35}
arr2={0:6,1:8,2:6,3:17,4:65,5:65,6:34}
Sorted L
should be [2,1,3,5,4,0,6]
, ordering between 1 and 2 is decided by arr2
, so does the ordering between 3 and 5. Rest of the ordering are decided by arr1
.