我有关键值对。键是String
,值是整数。我想按降序对它进行排序,以便首先显示具有最高值的元素。
如何按降序对排序集进行排序?
答案 0 :(得分:1)
您可以使用TreeMap执行此操作,例如:
LineCharts
如果您希望按值排序,那么您可以这样做:
// Create and set LineChart
var lineChart = LineChartView()
lineChart.descriptionText = ""
lineChart.delegate = self
lineChart.noDataTextDescription = "You need to provide data for the chart."
lineChart.drawGridBackgroundEnabled = false
lineChart.userInteractionEnabled = false
lineChart.xAxis.drawAxisLineEnabled = false
lineChart.xAxis.drawGridLinesEnabled = false
lineChart.xAxis.drawLabelsEnabled = false
lineChart.drawBordersEnabled = false
lineChart.leftAxis.enabled = false
lineChart.rightAxis.enabled = false
lineChart.legend.enabled = false
lineChart.contentMode = .ScaleAspectFill
lineChart.autoresizingMask = UIViewAutoresizing.FlexibleWidth