Ask Your Question
1

How do you sort Beker and Piper characteristic frequencies in order from least common to most common frequency?

asked 2020-09-07 17:48:23 +0100

Hoeckin gravatar image

Hello, I am trying to figure out how to sort the characteristic frequency of each letter in the table for beker and piper. I currently only have the code that will output the beker and piper table in order from the alphabet but I was wondering if there is a way to sort them from least to greatest based on their frequency?

Any information helps and here is the code I have so far

N = AlphabeticStrings()

table = N.characteristic_frequency(table_name="beker_piper")

sorted(table.items())

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-09-08 10:15:31 +0100

tmonteil gravatar image

updated 2020-09-08 10:15:47 +0100

You can provide a key function to sort with, as follows (say you want the most frequent letter first):

sage: sorted(table, key=table.get, reverse=True)                                                                                                                                                             
['E',
 'T',
 'A',
 'O',
 'I',
 'N',
 'S',
 'H',
 'R',
 'D',
 'L',
 'C',
 'U',
 'M',
 'W',
 'F',
 'G',
 'Y',
 'P',
 'B',
 'V',
 'K',
 'J',
 'Q',
 'X',
 'Z']
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-09-07 17:48:23 +0100

Seen: 183 times

Last updated: Sep 08 '20