by Ricardo Fernández Serrata
The infamous, inefficient sorting algorithm, ported to AM. The runtime is halved (optimized) because it checks whether the list is sorted in ascending or descending order.
This means there is 50% probability of the output being in either ascending or descending order. So the average runtime is O((n+1)! / 2). Best and worst cases are the same as stated in Wikipedia.
"Variable set out to inp" is used only because if the flow was running for a long time, it will remind you the original input.
Rate and review within the app in the Community section.