Sir I have x[n] variable & have different numbers/value in intiger assign to it (for eg x=2, x=7… … x[n-1]=3 etc). I need to write a program for the ascending or descending order of all variable x[n] inorder of its assigned value. if i use if /else loop then it will become more complicated. kindly tell me is there any shortest method to solve this type of problem?
If I understand you question, any sorting algorithm should work. Maybe you can phrase your question better.
if i have number 2341
do u mean i have to make it largest number possible and shortest number possible
like for above example
please give clarity otherwise we can’t help you.
i edit my question. plz see it.
Still can’t understand . Please post question link.
@mkmitra I think you want to know about inbuilt sorting function so that you can implement sorting without use of loops/ if-else statement.
make sure you
to sort in ascending/descending order you can use inbuilt sort() function.
sort(x, x + n) //n is size of array <–for sorting in ascending order
and for sorting in descending order we use
sort(x, x + N,greater<int>())
I hope this solves your doubt