Initial implementation of sort