Cleaned up sorting code wrt asc/desc order and added sort by size option.