Ready to sort

Statistics

Status Idle
Operations 0 / 0

Controls

50
5x

Summary

Stalin Sort operates under a simple, authoritarian principle: any element that disrupts the established order must be eliminated. It iterates through a list just once, establishing an ordered 'collective' of elements. Any 'comrade' (element) found to be smaller than the last loyal member of the collective is deemed a traitor and is permanently removed. The result is a perfectly sorted—albeit potentially much shorter—list, achieved with O(n) efficiency.

How it Works

  • The first element is declared the first loyal comrade, establishing the initial standard for the sorted collective.

  • Iterate through the remaining elements one by one.

  • Compare the current element to the last known loyal comrade.

  • If the current element is greater than or equal, it is deemed loyal and becomes the new standard.

  • If the current element is smaller, it is a traitor. It is immediately purged from the array.

  • The process continues until every element has been judged. The remaining elements form the final, sorted state.