function selection_sort(items):

   for i from 0 to length(items) - 1:
      smallest = i
      for j from i + 1 to length(items) - 1:
        if items[j] < items[smallest]:
           smallest = j
      swap(items, i, smallest)

   return items        # O(n^2) comparisons, few swaps
