💻CHALLENGE: Sort the lettres of a string alphabetically🔤 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

💻CHALLENGE: Sort the lettres of a string alphabetically🔤

Challenge: Split a string in chunks containing same characters. These chunks must be organized alphabetically. Example: "aaabcdbdbeffcf" -> ["aaa", "bbb", "cc", "dd", "e", "fff"] Happy coding🙂

27th Sep 2017, 8:49 PM
Samuel Šúr
Samuel Šúr - avatar
10 Answers
28th Sep 2017, 12:59 AM
Kartikey Sahu
Kartikey Sahu - avatar
+ 11
27th Sep 2017, 10:47 PM
Tashi N
Tashi N - avatar
+ 9
Here's my C# implementation! ✌ LINQ One-Liner〰 str .OrderBy(c => c) .GroupBy(c => c) .Select(g => string.Concat(g.ToList())) This is relatively easy in C# compared to the recent similar challenge. Enjoy~ ❤ P/S: Duplicate found @ https://www.sololearn.com/Discuss/746250/?ref=app https://code.sololearn.com/cnp3Ko6ssHzM/?ref=app
28th Sep 2017, 4:25 AM
Zephyr Koo
Zephyr Koo - avatar
+ 9
https://code.sololearn.com/cJB1BRIuW5BB/#java
28th Sep 2017, 3:49 PM
Vukan
Vukan - avatar
+ 6
My try, this challenge similar to cut a string challenge, I just modified that code a bit, a bit rough though https://code.sololearn.com/cWzRvm0P3TRm/?ref=app
28th Sep 2017, 7:08 AM
David Akhihiero
David Akhihiero - avatar
28th Sep 2017, 12:48 PM
Isnan Mulia
Isnan Mulia - avatar
28th Sep 2017, 11:27 AM
m_sudhu
m_sudhu - avatar
+ 1
I used Hash for grouping letters, and then sorted the list. https://code.sololearn.com/cmE1BCKl7VN0/?ref=app
29th Sep 2017, 2:20 AM
Hiroki Masuda
Hiroki Masuda - avatar
29th Sep 2017, 3:05 PM
ⵢⴷⵢⴷ
ⵢⴷⵢⴷ - avatar