sortingx-1.2.0
download:
!pip install sortingx==1.2.0 # in jupyter
pip install sortingx==1.2.0 # in cmd
examples:
import sortingx as six
data = [('Alex', 100, 90, 98, 95), ('Jack', 97, 88, 98, 92), ('Peter', 92, 95, 92, 96), ('Li', 97, 89, 98, 92)]
result = sorted(data, key=lambda x: (x[0], x[1]), reverse=True) # data will be deepcopyed in sorted.
output = six.bubble(data, key=lambda x: (x[0], x[1]), reverse=True)
print(output == result, data == result) # `output` is the return value of `data`.
'''
True, True
'''
more:
import sortingx as six
data = {('Alex', 100, 90, 98, 95), ('Jack', 97, 88, 98, 92), ('Peter', 92, 95, 92, 96), ('Li', 97, 89, 98, 92)} # set
# data = (('Alex', 100, 90, 98, 95), ('Jack', 97, 88, 98, 92), ('Peter', 92, 95, 92, 96), ('Li', 97, 89, 98, 92)) # tuple
output = six.bubble(data, key=lambda x: (x[0], x[1]), reverse=True) # # when data is not `list` type, it will be converted to list. data remains its type.
result = sorted(data, key=lambda x: (x[0], x[1]), reverse=True)
print(output == result)
'''
True
'''
some cases for str, dict:
str_ = six.merge("barzilar_borwein") # str
dict_ = six.quick({'Alex': 100, 'Jack': 97, 'Peter': 88, 'Li': 98}) # dict (sort by key)
explain:
- the kernel of
generate
can better cooperate withcore
function than previous 4 versions. - comparison of
str
has been optimized compared with v1.1.2 and v1.1.3.