I was sorting the original input, which messed up the column order.