Implementation of sort algorithms