diff --git a/def/sortingCriteria.go b/def/sortingCriteria.go index b4b6213..e595266 100644 --- a/def/sortingCriteria.go +++ b/def/sortingCriteria.go @@ -1,13 +1,13 @@ package def // the sortBy function that takes a task reference and returns the resource to consider when sorting. -type sortBy func (task *Task) float64 +type sortBy func(task *Task) float64 // Possible Sorting Criteria // Each holds a closure that fetches the required resource from the // given task reference. var ( - SortByCPU = func (task *Task) float64 {return task.CPU} - SortByRAM = func (task *Task) float64 {return task.RAM} - SortByWatts = func (task *Task) float64 {return task.Watts} + SortByCPU = func(task *Task) float64 { return task.CPU } + SortByRAM = func(task *Task) float64 { return task.RAM } + SortByWatts = func(task *Task) float64 { return task.Watts } ) diff --git a/def/taskUtils.go b/def/taskUtils.go index bbe53d7..733754e 100644 --- a/def/taskUtils.go +++ b/def/taskUtils.go @@ -2,8 +2,8 @@ package def import ( "github.com/mdesenfants/gokmeans" - "sort" "log" + "sort" ) // Information about a cluster of tasks @@ -118,7 +118,7 @@ func labelAndOrder(clusters map[int][]Task, numberOfClusters int, taskObservatio // Generic Task Sorter. // Be able to sort an array of tasks based on any of the tasks' resources. func SortTasks(ts []Task, sb sortBy) { - sort.SliceStable(ts, func (i, j int) bool { + sort.SliceStable(ts, func(i, j int) bool { return sb(&ts[i]) <= sb(&ts[j]) }) }