Back to KinderGarten II : Where's Aïcha ? (eeeasy)
Description:
So, Odile has printed the list of kids and pinned it to the wall. (If you've not solved the previous "Back to KinderGarten" kata you may click on Odile, above)
But ... What ?!? Why the hack is "Aïcha" sorted after "Anas" or "Léo" after "Lucy" ?
It seems "extended characters" (like ï
or é
) cause some problems. Odile needs to re-code her sorting function.
By the way, she thinks also about sorting kids with same (first) name. She decides to sorted them by Ages (youngest first).
Task
As previously, you should create 2 functions : parseKidList
and sortByNamesAndAges
(instead of sortByNames )
parseKidList( csv )
: receives a "csv-string" representing a list of kids, each separated from other by a newline ("\n
") and composed ofName,DateOfBirth,Gender
-values, separated by comma (",
")sortByNamesAndAges( kids )
: receives as argument the "thing" obtained with previous function and should return an array of "kids", sorted in ascending order by names, and ages if names are the same.- A "kid" in the output list should be of the form "NAME (G) dd/mm/yyyy" ( ie name in uppercase, gender (m or f) in uppercase and between parenthesis, and DoB in dd/mm/yyyy format)
Notes :
- Tested extended characters are only "
É, é, è, ë, ï or ù
" - When kids should be sorted by age it means younger before older.
Examples
var kids = parseKidList( ["Lucy,2/12/2012,f\nLéo,1/1/2013,m"] );
parseByNamesAndAges( kids ) // -> ["LÉO (M) 01/01/2013", "LUCY (F) 02/12/2012"] because "`Ï`" is considered as a "`I`" and then before "`U`";
kids = parseKidList( ["Pat,2/12/2012,f\nPat,1/1/2013,m"] );
parseByNamesAndAges( kids ) // -> ["PAT (M) 01/01/2013", "PAT (F) 02/12/2012"] because PAT the boy is younger (2013) than PAT the girl (2012)
So back to work kids ! Odile needs your help !
Similar Kata:
Stats:
Created | Sep 17, 2016 |
Published | Sep 17, 2016 |
Warriors Trained | 77 |
Total Skips | 11 |
Total Code Submissions | 87 |
Total Times Completed | 19 |
JavaScript Completions | 19 |
Total Stars | 1 |
% of votes with a positive feedback rating | 90% of 10 |
Total "Very Satisfied" Votes | 9 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 10 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |