Open In App

Python | SymPy Partition.sort_key() method

Partition.sort_key() : sort_key() is a sympy Python library function that returns canonical key which can be used for string. This ordering of canonical key is based on the size and the elements of the partition whose ties are broken with the rank.

Syntax : sympy.combinatorics.partitions.Partition.sort_key() 



Return : Canonical key which can be used for string

Code #1 : sort_key() Example 



Python3 1=1

 

Output : 

[{{3, 4}}, {{44, x}}, {{44, x}}, {{134}, {322}}, {{0, 1, 2}}]

Code #2 : sort_key() Example 

Python3 1=1

 

Output : 

[{{44, x, y}}, {{3, 4, 12, 55}}]

Article Tags :