How can we sort an integer digits by its digits value | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 25

How can we sort an integer digits by its digits value

for example we input 58218 how can we rearrange its digits to output 88521 or we input 1324 and it output 4321? (in c++)

20th May 2018, 6:27 PM
AliR૯za
AliR૯za - avatar
6 Answers
20th May 2018, 6:42 PM
🇮🇷 M N
+ 21
🇮🇷 M N perfect , Thank you😍
20th May 2018, 6:46 PM
AliR૯za
AliR૯za - avatar
+ 19
Hatsy Rei Awesome 👍
3rd Jun 2018, 9:53 AM
AliR૯za
AliR૯za - avatar
+ 10
🇮🇷 M N Thanks for the code!
30th May 2018, 2:21 AM
Annie
Annie - avatar
+ 4
Hail the STL babyyy. It sorts in ascending order, so all you have to modify is to do std::reverse or write a sort implementation struct for std::sort. https://code.sololearn.com/c7p6nes53u2Y/?ref=app
3rd Jun 2018, 8:53 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
its having many sorting algorithms that can be used to sorting the values
29th May 2018, 6:06 PM
Pradheepviki😎😀
Pradheepviki😎😀 - avatar