7 kyu

Alphabetize a list by the nth character

908 of 2,036edm2410

Description:

Write a function that accepts two parameters, i) a string (containing a list of words) and ii) an integer (n). The function should alphabetize the list based on the nth letter of each word.

The letters should be compared case-insensitive. If both letters are the same, order them normally (lexicographically), again, case-insensitive.

Example:

function sortIt('bid, zag', 2) //=> 'zag, bid'
function sortIt('bid, zag', 2) //=> 'zag, bid'
sort_it('bid, zag', 2) #=> 'zag, bid'
sortIt ["bid", "zag"] 2 `shouldBe` ["zag", "bid"]

The length of all words provided in the list will be >= n. The format will be "x, x, x". In Haskell you'll get a list of Strings instead.

Lists
Strings
Sorting
Arrays
Fundamentals

Stats:

CreatedFeb 26, 2015
PublishedFeb 26, 2015
Warriors Trained4582
Total Skips460
Total Code Submissions15068
Total Times Completed2036
JavaScript Completions767
Ruby Completions315
Python Completions908
Haskell Completions93
Total Stars60
% of votes with a positive feedback rating79% of 305
Total "Very Satisfied" Votes219
Total "Somewhat Satisfied" Votes45
Total "Not Satisfied" Votes41
Ad
Contributors
  • edm2410 Avatar
  • jhoffner Avatar
  • bkaes Avatar
  • GiacomoSorbi Avatar
  • Voile Avatar
  • solitude Avatar
  • Wei-Ting Yang Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad