如何通过它的组件进行排序String数组? Java的 [英] How to sort String array by its component? Java

查看:75
本文介绍了如何通过它的组件进行排序String数组? Java的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Date,Lat,Lon,Depth,Mag
20000101,34.6920,-116.3550,12.30,1.21
20000101,34.4420,-116.2280,7.32,1.01
20000101,37.4172,-121.7667,5.88,1.14
20000101,-41.1300,174.7600,27.00,1.90
20000101,37.6392,-119.0482,2.40,1.03
20000101,32.1790,-115.0730,6.00,2.44
20000101,59.7753,-152.2192,86.34,1.48
20000101,34.5230,-116.2410,11.63,1.61
20000101,59.5369,-153.1360,100.15,1.62
20000101,44.7357,-110.7932,4.96,2.20
20000101,34.6320,-116.2950,9.00,1.73

我需要每个标准对这些数据进行排序

I need to sort these data by each criterion

我试过 Double.parseDouble(数组[0] .split()。[1]),但使用的选择需要太多的时间排序

I tried Double.parseDouble(array[0].split(",").[1]) but takes too much time using Selection Sort

有什么办法,只是有点不使用parseDouble?

Is there any way to just sort by not using parseDouble?

推荐答案

您有您希望通过PTED为Double某子间$ P $排序字符串,所以没办法解决它们解析。但是,如果你分析每一行一次,并保存这些结果进行排序,这将是比每个比较中调用parseDouble更快。

You have strings that you want to sort by a certain substring interpreted as a Double, so no way around parsing them. But if you parse each line once, and save those results to sort on, that will be faster than calling parseDouble within each comparison.

这篇关于如何通过它的组件进行排序String数组? Java的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆