![image](https://private-user-images.githubusercontent.com/56733438/288240576-e2a4cc04-f1f8-4c0c-baac-4c1c81498b8b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMDkzNDIsIm5iZiI6MTcyNDEwOTA0MiwicGF0aCI6Ii81NjczMzQzOC8yODgyNDA1NzYtZTJhNGNjMDQtZjFmOC00YzBjLWJhYWMtNGMxYzgxNDk4YjhiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDIzMTA0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFjOWY4OTY2N2NkMjU2YjdjYjliOWQwY2U4NTZlN2JiZmM5MWFhYjg0NDNjNjA0YWUzMDQzZmU2MjRlMTMwNTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Z8onf5_lW7vPk7HUAksL6Extj_QggNLLVf6pOjr9tAo)
push_swap is a sorting algorithm based on sorting two stacks with the least amount of moves. The allowed moves are:
- sa (swap a): Swap the first 2 elements at the top of stack a.
- sb (swap b): Swap the first 2 elements at the top of stack b.
- ss : sa and sb at the same time.
- pa (push a): Take the first element at the top of b and put it at the top of a.
- pb (push b): Take the first element at the top of a and put it at the top of b.
- ra (rotate a): Shift up all elements of stack a by 1. First becomes last.
- rb (rotate b): Shift up all elements of stack b by 1. First becomes last.
- rr : ra and rb at the same time.
- rra (reverse rotate a): Shift down all elements of stack a by 1. Last becomes first.
- rrb (reverse rotate b): Shift down all elements of stack b by 1. Last becomes first.
- rrr : rra and rrb at the same time.
By using these moves, the goal is to sort the numbers in stack A in ascending order, using stack B as a temporary storage.
This algorithm is considered to be one of the simplest sorting algorithm, but it can be quite hard to optimize it and sort a large amount of numbers with a low amount of moves.