exam TStu TExam
1 91 25
2 168 20
3 2080 46
4 680 56
5 15 12
6 680 22
7 166 20

How to sort in descending order like this..

4 680 56
3 2080 46
1 91 25
....................................

Recommended Answers

All 2 Replies

Hey Sorting is a huge topic and there are several ways of sorting the data.
which technique you want to use to sort this data.
Radix sort can do a job.
lets understand what you want

1 91 25
2 168 20
3 2080 46
4 680 56
5 15 12
6 680 22
7 166 20

you want to start sorting the data from the last two digits.
Algorithm goes like this.
read the list of numbers in arrays.
use suitable sorting algorithm.
the tricky part is how you would get the last two numbers to do comparision (if you are using comparision sorting technique). ? (its simple dear, try gettting the
(number % 100). it will give you last two digits. :).
Perform sorting.


Hope this help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.