func isNaN(f float64) bool {
	return f != f
}
isNaN is a copy of math.IsNaN to avoid a dependency on the math package.
package quickselect
import (
	"container/heap"
	"errors"
	"fmt"
	"math/rand"
)
const (
	partitionThreshold            = 8
	naiveSelectionLengthThreshold = 100
	naiveSelectionThreshold       = 10
	heapSelectionKRatio           = 0.001
	heapSelectionThreshold        = 1e3
)
type Interface interface {
	Len() int
	Less(i, j int) bool
	Swap(i, j int)
}
type reverse struct {
	Interface
}
func (r reverse) Less(i, j int) bool {
	return r.Interface.Less(j, i)
}
func Reverse(data Interface) Interface {
	return &reverse{data}
}
type IntSlice []int
func (t IntSlice) Len() int {
	return len(t)
}
func (t IntSlice) Less(i, j int) bool {
	return t[i] < t[j]
}
func (t IntSlice) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}
func (t IntSlice) QuickSelect(k int) error {
	return QuickSelect(t, k)
}
type Float64Slice []float64
func (t Float64Slice) Len() int {
	return len(t)
}
func (t Float64Slice) Less(i, j int) bool {
	return t[i] < t[j] || isNaN(t[i]) && !isNaN(t[j])
}
func (t Float64Slice) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}
func (t Float64Slice) QuickSelect(k int) error {
	return QuickSelect(t, k)
}
type StringSlice []string
func (t StringSlice) Len() int {
	return len(t)
}
func (t StringSlice) Less(i, j int) bool {
	return t[i] < t[j]
}
func (t StringSlice) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}
func (t StringSlice) QuickSelect(k int) error {
	return QuickSelect(t, k)
}