Sort Function

Developed correct sort function to allow the browse sorting to work
correctly.