copied quick sort from somewhere else