Implementation of quick sort