Sorting is a very common algorithm that we use to rearrange a list of numbers or objects in an ascending or descending order. A more technical definition of sorting is as follows:
In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order.
Now, let's assume that you have a list of n items, and you want to sort them. You take all the n items and determine all the possible sequences in which you can place these items, which, in this case, would be n! in total. We now need to determine which of these n! series does not have any inverted pairs to find out the sorted list. An inverted pair is defined as a pair of elements whose position in the list is represented by i, j where i < j, but the values xi > xj.
Of course, the preceding method is tedious and requires some heavy computation...