0

Need some explanation on my code here

The purpose of this code is to sort the values of the array in ascending/ descending order. I'm having trouble with the multiple for loop part, that I can't wrap my head around it for days. https://code.sololearn.com/cKT6JZ1Ya7nI/?ref=app Also is there another way of writing the loops?

12th Sep 2019, 8:48 AM
Rae
Rae - avatar
4 Answers
12th Sep 2019, 11:25 AM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
12th Sep 2019, 12:20 PM
MO ELomari
MO ELomari - avatar
+ 1
Your code is almost correct..but due to some logical errors it doesn't work.. First thing you have to use curly braces for if else statements unless it has only one line of code... Eg if(condition) //One line statement (correct) if(condition) // Some part //Some part This will not give syntax error but if condition is false then first line won't execute..(try it) And about logical errors, try thinking about it or understand it by drawing or writing, how it works on paper.. Hint:- check conditions in both loops.. Try tracing your code on paper and you will know where you are wrong..
12th Sep 2019, 4:08 PM
Alaska
Alaska - avatar
0
This is definitely something that I had never seen! I'll do my best understanding the code you wrote. Also thanks for taking the time to help me it means a lot.
12th Sep 2019, 11:47 AM
Rae
Rae - avatar