如何对值进行排序 [英] how to sort the values

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

问题描述

我有一些需要排序的键值对文件,值r


1306014503350001,0.7167574
1371031512360001,0.4335363
1371054509380001,2.3803377
1671046105520001,1.4315698
1810041005700002,0.030490799
1903034506620003,0.44315025
3171011804580003,0.72508544
3171015707400001,0.82567614
3171016009600004,0.44152263
3171077112400014,0.32794788
3171080502520003,0.46428326
3173010903500003,0.40578112
3173014203420002,0.67425823
3173015811550002,2.4808035
3174095204390002,0.9443519
3175036405300002,2.0835547
3175044211580002,0.3450352


需要根据comma(,)之后的值进行排序.根据dat整数值应进行b排序,但o/p应按i/p文件中的b进行排序,从某种意义上说,整数应b首先

I hav a file of some key value pairs need to sort,values r


1306014503350001,0.7167574
1371031512360001,0.4335363
1371054509380001,2.3803377
1671046105520001,1.4315698
1810041005700002,0.030490799
1903034506620003,0.44315025
3171011804580003,0.72508544
3171015707400001,0.82567614
3171016009600004,0.44152263
3171077112400014,0.32794788
3171080502520003,0.46428326
3173010903500003,0.40578112
3173014203420002,0.67425823
3173015811550002,2.4808035
3174095204390002,0.9443519
3175036405300002,2.0835547
3175044211580002,0.3450352


need to sort based on values after comma(,).According to dat integer values should b sorted but o/p should b as it is in i/p file in the sense integers should b first

推荐答案

使用命令提示符,如下所示:
Use the command prompt as follows :
c:\> sort input.txt > output.txt


打开Excel,单击半英寸直径的色带图标,然后单击鼠标,单击新建的/空白工作簿,然后在选项卡上单击鼠标在电子表格的底部,删除sheet3和sheet2.然后单击上方的数据"选项卡,选择来自文本"按钮,将鼠标移至包含上述数据的文本文件所在的目录,选择打开",然后在弹出对话框时选择定界".然后在下一个面板中选择逗号"定界符.

最终选择"A1 ...确定".

现在您有两列数据.

使用鼠标选择所有数据,然后在主页"选项卡下,选择排序过滤器/自定义过滤器",然后在弹出对话框时,选择要对其进行排序的列.

适当地折叠列表后,将文件另存为.txt.

或者看起来不错的东西,或者您发现它比.txt更有用.

[edit]

关闭Excel.

[edit]
Open Excel, click-on the half-inch diameter ribbon icon-thingy, click-on new/ blank-workbook create, mouse on down to the tabs at the bottom of the spreadsheet, delete sheet3 and sheet2. Then click-on Data tab back above, select "From text" button, mouse to the directory containing your textfile with the above data in it, choose open and when the dialog pops up choose delimited. Then choose, in the next panel "comma" delimiter.

Eventally choose "A1 ...ok".

And now you''ve got two columns of data.

Select all the data using your mouse, then, back under the "home" tab, choose "sort filter/custom filter" and when the dialog pops up, choose the column you want to sort on.

Once the list is appropriately plied, save the file as .txt.

Or whatever looks good or you find more useful than .txt.

[edit]

Close Excel.

[edit]


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;



public class validate2 
{
	private Map<double,> dataMap = null;
	
	public static void main(String[] args) throws IOException {
		
		String dataFileName = "E://abc1.txt";
		Validate validate = new Validate();
		validate.initializeData(dataFileName);
		validate.printData();
		}
	public String getValue(Double key) 
	{
		String value = null;
		Long longValue = null;
	
		if ((longValue=dataMap.get(key)) == null) 
		{
			value = "value is null";
			
		} else {
			value = longValue.toString();
			
		}
		return value;
	}
}



================================================== ============================
**这是我的工作,这是错误的,起初我需要获取整数值&稍后的float值**

306014503350001,0.7167574
1371031512360001,0.4335363
1371054509380001,2.3803377
1671046105520001,1.4315698

o/p应该以上述格式b进行aftr排序
================================================== ===========================



================================================================================
**this is my work, which is wrong,at first i need to get the integer values & later float values**

306014503350001,0.7167574
1371031512360001,0.4335363
1371054509380001,2.3803377
1671046105520001,1.4315698

o/p should b in above format aftr sorting
===============================================================================


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

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