Open In App

Python | SymPy Partition.sort_key() method

Last Updated : 30 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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}}]


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads