6 kyu

Sort the comments!

Description:

Background

One way to order a nested (reddit-style) commenting system is by giving each comment a rank.

Generic comments on a thread start with rank 1 and increment, so the second comment on a thread would have rank 2. A reply to comment 1 will be ranked 1.1, and a reply to comment 1.1 will be ranked 1.1.1 . The second comment to reply to comment 1 would be ranked 1.2 .

Note that since 1.1.1 is a valid rank, the ranks given are of type string.

Task:

Given a list of comment ranks (strings), order them as a comment thread would appear

Assumptions:

  • there will always be a rank 1 in the given input
  • ranks are of type string
  • rank numbers are incremented, and not skippped (1.1 could be followed by 1.2, not 1.3)

Example order:

[
  '1',
  '1.1',
  '1.2',
  '1.2.1',
  '2',
  '3',
  '3.1',
  '3.1.1',
  '3.2'
]
Sorting
Algorithms

Stats:

CreatedFeb 12, 2017
PublishedFeb 12, 2017
Warriors Trained729
Total Skips19
Total Code Submissions1432
Total Times Completed268
Python Completions268
Total Stars29
% of votes with a positive feedback rating93% of 92
Total "Very Satisfied" Votes82
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes3
Total Rank Assessments12
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • danarters Avatar
  • ChristianECooper Avatar
  • dfhwze Avatar
  • saudiGuy Avatar
Ad