Skip to content
Hello world

Hello world

May 12, 2026

Hello world.

Here is a small Python implementation of gnome sort:

def gnome_sort(items):
    items = list(items)
    index = 0

    while index < len(items):
        if index == 0 or items[index] >= items[index - 1]:
            index += 1
        else:
            items[index], items[index - 1] = items[index - 1], items[index]
            index -= 1

    return items


if __name__ == "__main__":
    numbers = [5, 3, 8, 1, 2]
    print(gnome_sort(numbers))