in pkg/sorter/sorter.go [91:120]
func Sort(instanceTypes []*instancetypes.Details, sortField string, sortDirection string) ([]*instancetypes.Details, error) {
sortingKeysMap := map[string]string{
VCPUs: vcpuPath,
Memory: memoryPath,
GPUMemoryTotal: gpuMemoryTotalPath,
NetworkInterfaces: networkInterfacesPath,
SpotPrice: spotPricePath,
ODPrice: odPricePath,
InstanceStorage: instanceStoragePath,
EBSOptimizedBaselineBandwidth: ebsOptimizedBaselineBandwidthPath,
EBSOptimizedBaselineThroughput: ebsOptimizedBaselineThroughputPath,
EBSOptimizedBaselineIOPS: ebsOptimizedBaselineIOPSPath,
}
// determine if user used a shorthand for sorting flag
if sortFieldShorthandPath, ok := sortingKeysMap[sortField]; ok {
sortField = sortFieldShorthandPath
}
sorter, err := newSorter(instanceTypes, sortField, sortDirection)
if err != nil {
return nil, fmt.Errorf("an error occurred when preparing to sort instance types: %v", err)
}
if err := sorter.sort(); err != nil {
return nil, fmt.Errorf("an error occurred when sorting instance types: %v", err)
}
return sorter.instanceTypes(), nil
}