updated files to implement sorting at different levels. currently incomplete