Sort an array of integers to three buckets, given dual pivots