In the one and only true way. The object-oriented version of 'Spaghetti code' is, of course, 'Lasagna code'. (Too many layers). Roberto Waltman
The exchange sort is a sorting algorithm that compares each item with other items of the array and swap the item if requires.
Sort the items by exchanging pairs of items until the sequence is sorted. In general, an algorithm may exchange adjacent elements as well as widely separated one.
Unsorted array before sorting: [12, 11, 13, 5, 6, 7] Sorted array After Exchange Sort sorting: [5, 6, 7, 11, 12, 13]