7 kyu

Sort deck of cards

750 of 1,546filipkonieczny

Description:

Write a function sort_cards() that sorts a shuffled list of cards, so that any given list of cards is sorted by rank, no matter the starting collection.

All cards in the list are represented as strings, so that sorted list of cards looks like this:

['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']

Example:

>>> sort_cards(['3', '9', 'A', '5', 'T', '8', '2', '4', 'Q', '7', 'J', '6', 'K'])
['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']

Hint: Tests will have many occurrences of same rank cards, as well as vary in length. You can assume though, that input list is always going to have at least 1 element.

Fundamentals
Algorithms
Lists
Sorting

Stats:

CreatedMar 24, 2016
PublishedMar 24, 2016
Warriors Trained2669
Total Skips48
Total Code Submissions3898
Total Times Completed1546
Python Completions750
Java Completions322
JavaScript Completions525
Total Stars52
% of votes with a positive feedback rating91% of 310
Total "Very Satisfied" Votes264
Total "Somewhat Satisfied" Votes38
Total "Not Satisfied" Votes8
Total Rank Assessments15
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • filipkonieczny Avatar
  • zebulan Avatar
  • suic Avatar
  • adamb Avatar
  • iamchingel Avatar
  • saudiGuy Avatar
Ad