How can we sort an integer digits by its digits value | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
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