Frequency Sort

Sort a list by a frequency distribution. Frequency is calculated as per a a provided function. In the test case a list of lists is sorted by the frequency of the length of the lists.