Error: Protected edit requests can only be made on the talk page.

IndexSort
File:Empty
Example of IndexSort. starting with first value and switching by its index, if correct place go next one, repeated until done.
ClassSorting algorithm
Data structureArray
Worst-case performancenot tested, so probally:
Best-case performancenot tested, so probally:
Average performanceprobally:
Worst-case space complexity as it don't use auxiliary arrays [1]

idk what here so other do fill it

Algorithm

edit

basicly it works:

  1. take first value of array (called current) and go to array[current - 1] and switch places with other value same index as current, then continuing on first value do same repeatly
  2. if array[current - 1] is same as current - 1, it will go to 2nd value, and repeated until sorted

implementation/code

edit

we will use python for this example

def Indexsort(arr):
    current = 0
    n = len(arr)
    while current < n:
        target = arr[current] - 1 
        if 0 <= target < n and arr[current] != arr[target]:
            arr[current], arr[target] = arr[target], arr[current]
        else:
            current += 1

note

edit
  1. current implementation likely crash if there repeated values
  2. needed gif image
  3. still under maintence, don't expect alot from it
  1. ^ Skiena (2008, p. 122)