Rating:

TL;DR: Use 2 stacks to sort

Original writeup (https://dunsp4rce.github.io/rgbCTF-2020/misc/2020/07/14/Laser-2-Sorting.html).