Horje
python sort list by rule Code Example
python sort list by rule
# adapted from answer given by Stack Overflow user in the source link

my_list = list(...) # this is your list

# my_rule() is a custom function applied on elements of list that must return a number
# in this way, the "real" sorting will be performed by considering the outcome of my_rule()
# reverse: False to sort element in ascending order
rule_sorted_list = sorted(my_list, lambda x: my_rule(x), reverse = False)

# Note: if your list contains number only, then just write sorted(my_list) to sort it




Python

Related
python print \n every n loops Code Example python print \n every n loops Code Example
mount gdrive in pyton Code Example mount gdrive in pyton Code Example
how to find out the max and min date on the basis of property id in pandas Code Example how to find out the max and min date on the basis of property id in pandas Code Example
python sys environment Code Example python sys environment Code Example
python run bat in new cmd window Code Example python run bat in new cmd window Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8