C++ implementation of a sorting algorithm for rearranging railroad cars