reverse stack and sort
test
merging changes
with rachel's functions