6 kyu
Lexographic sort with a twist
Description:
My 6th kata, implement a lexicographic sort order to make longer items go before any of their prefixes.
In Python, write a function (custom_sort
) that takes an input list (lst
) of strings. The function should return a new list of strings sorted lexiographically but with longer items before their prefixes. The test cases give some examples.
You can assume that all strings will consist of ASCII printable characters and that the largest character will be '~'
, which is chr(126)
. For an extra challenge code a solution that makes no such assumptions.
Do vote and provide any feedback on the kata.
If you like this kata, do checkout my other katas.
Algorithms
Arrays
Sorting
Data Structures
Similar Kata:
Stats:
Created | Apr 27, 2017 |
Published | Apr 27, 2017 |
Warriors Trained | 439 |
Total Skips | 31 |
Total Code Submissions | 834 |
Total Times Completed | 98 |
Python Completions | 98 |
Total Stars | 14 |
% of votes with a positive feedback rating | 89% of 45 |
Total "Very Satisfied" Votes | 38 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |