Added functional ternery quick sort