Internal sort

Source: Wikipedia, the free encyclopedia.

An internal sort is any data sorting process that takes place entirely within the

sort algorithms
.

Some common internal sorting algorithms include:

  1. Bubble Sort
  2. Insertion Sort
  3. Quick Sort
  4. Heap Sort
  5. Radix Sort
  6. Selection sort

Consider a

Bubblesort
, where adjacent records are swapped in order to get them into the right order, so that records appear to “bubble” up and down through the dataspace. If this has to be done in chunks, then when we have sorted all the records in chunk 1, we move on to chunk 2, but we find that some of the records in chunk 1 need to “bubble through” chunk 2, and vice versa (i.e., there are records in chunk 2 that belong in chunk 1, and records in chunk 1 that belong in chunk 2 or later chunks). This will cause the chunks to be read and written back to disk many times as records cross over the boundaries between them, resulting in a considerable degradation of performance. If the data can all be held in memory as one large chunk, then this performance hit is avoided.

On the other hand, some algorithms handle

Quick sort
) and then recombines the chunks two by two so that each recombined chunk is in order. This approach minimises the number or reads and writes of data-chunks from disk, and is a popular external sort method.