6 kyu

Emotional Sort ( ︶︿︶)

1,392 of 3,025Phares

Description:

Emotional Sort ( ︶︿︶)

You'll have to create a function that will return an array of emotions sorted. It has two parameters, the first parameter called will expect an array of emotions where an emotion will be one of the following:

  • :D -> Super Happy
  • :) -> Happy
  • :| -> Normal
  • :( -> Sad
  • T_T -> Super Sad

Example of the array:[ "T_T", ":D", ":|", ":)", ":(" ]

And the second parameter will expect a boolean. If this parameter is true then the order of the emotions will be descending (from Super Happy to Super Sad) if it's false then it will be ascending (from Super Sad to Super Happy)

Example if order is true with the above array: [ ":D", ":)", ":|", ":(", "T_T" ]

  • Super Happy -> Happy -> Normal -> Sad -> Super Sad

If order is false: [ "T_T", ":(", ":|", ":)", ":D" ]

  • Super Sad -> Sad -> Normal -> Happy -> Super Happy

Example:

array: [":D", ":|", ":)", ":(", ":D"]
order: true 
should return [ ":D", ":D", ":)", ":|", ":(" ]

array: [":D", ":|", ":)", ":(", ":D"]
order: false
should return [ ":(", ":|", ":)", ":D", ":D" ]

More in test cases!

Notes:

  • The array could be empty, in that case return the same empty array ¯\_( ツ )_/¯
  • All emotions will be valid

Enjoy! (づ。◕‿‿◕。)づ

Arrays
Fundamentals
Sorting

More By Author:

Check out these other kata created by Phares

Stats:

CreatedFeb 15, 2018
PublishedFeb 15, 2018
Warriors Trained4508
Total Skips69
Total Code Submissions6362
Total Times Completed3025
JavaScript Completions1392
Ruby Completions114
Python Completions1312
Elixir Completions28
Factor Completions8
Java Completions241
Lua Completions8
Total Stars79
% of votes with a positive feedback rating95% of 489
Total "Very Satisfied" Votes448
Total "Somewhat Satisfied" Votes37
Total "Not Satisfied" Votes4
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Phares Avatar
  • zruF Avatar
  • adrian.eyre Avatar
  • rowcased Avatar
  • trashy_incel Avatar
  • 2015_6_7 Avatar
  • Kacarott Avatar
  • yLaWy Avatar
  • gifti Avatar
  • sergio.gd Avatar
  • PetitLu117 Avatar
Ad