Skip to content

sortingx-1.2.1

Compare
Choose a tag to compare
@linjing-lab linjing-lab released this 27 Dec 02:42
· 33 commits to main since this release

download:

!pip install sortingx==1.2.1 # in jupyter
pip install sortingx==1.2.1 # 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:

  • v1.2.1 is mainly the equivalent of v1.2.0, but the kernel of generate is more portable than v1.2.0.
  • delete core function to make comparision with built-in rules first.