// sort
package spiderutil

import (
	"sort"
)

type Info struct {
	Code, Name, TargetChannelUrl string //代码、名称、地址
	User, MUser, ChanelName      string //作者、维护人、栏目名称
	ClistNum                     int32  //列表页数据量
	CdownNum                     int32  //补漏数据量
}
type MsgInfoSort []*Info

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

func (list MsgInfoSort) Less(i, j int) bool {
	if list[i].CdownNum > list[j].CdownNum {
		return true
	} else if list[i].CdownNum < list[j].CdownNum {
		return false
	} else {
		return list[i].Code < list[j].Code
	}
}

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

func SortMap(list []*Info) []*Info {
	pList := MsgInfoSort(list)
	sort.Sort(pList)
	return pList
}
