// 抽取结果sort
package util

import (
	"sort"
)

type SortObject struct {
	Key      string
	Value    int
	ValueStr string
	Object   interface{}
}

type SortStruct []*SortObject

func (list SortStruct) Len() int {
	return len(list)
}

func (list SortStruct) Less(i, j int) bool {
	if list[i].Value > list[j].Value {
		return true
	} else if list[i].Value < list[j].Value {
		return false
	} else {
		return list[i].ValueStr > list[j].ValueStr
	}
}

func (list SortStruct) Swap(i, j int) {
	var temp *SortObject = list[i]
	list[i] = list[j]
	list[j] = temp
}

func ExtSort(list []*SortObject) []*SortObject {
	ls := SortStruct(list)
	sort.Sort(ls)
	return ls
}
