I have a list of object and I want to sort it but there is one caveat.
So lets say the list has an object which has an instance called norm
and norms are like [0.1,0.2,0.3.....0.9]
So if i do something like:
potential_list.sort(key = lambda x:x._norm, reverse = True)
then it will sort it in somethng like
[0.9, 0.8... 0.1]
but i want to sort it so wrt to a number so that
number = 0.3
then sorted list is [0.4,0.6,0.3,0.7 and so on] because
0.4-0.3 = 0.1
abs|0.4-0.5| = 0.1
0.4 - 0.2 = 0.2
abs|0.4 - 0.6| = 0.2
So the sort is because of that difference.
How do i do this. Not that these [0.4,0.6....] are an instance of any object
So its a mix of sorting a list with respect to the closest number in the list python and How to sort a list of objects , based on an attribute of the objects?