简体   繁体   English

使用vb.net在记事本中对多列进行排序

[英]Sort multiple column in notepad using vb.net

I am doing a project that requires me to transfer data from one notepad to another notepad (saved using excel tab delimited form). 我正在做一个项目,要求我将数据从一个记事本传输到另一个记事本(使用excel制表符分隔格式保存)。

I have successfully done that, the only that left is I need to sort those data after transferring it. 我已经成功做到了,剩下的就是我需要在传输数据之后对这些数据进行排序。

For your information, I am transferring 5 column from the first notepad to the second notepad. 供您参考,我正在将5列从第一个记事本转移到第二个记事本。 I saved those information in five arrays. 我将这些信息保存在五个阵列中。

How am I supposed to sort them after pasting? 粘贴后如何分类?

I tried using vb.net sort function but that only will sort one array while the rest of the arrays wont follow. 我尝试使用vb.net排序功能,但是只能排序一个数组,而其余的数组则不会。

I tried lines.sort also but the result is not satisfying, any other idea to sort those data like what we normally do manually in excel? 我也尝试了lines.sort,但结果不令人满意,还有其他想法像我们通常在excel中手动进行的那样对这些数据进行排序吗?

Any help will be very much appreciated. 任何帮助将不胜感激。

One solution would be to create an object with 5 values in it. 一种解决方案是创建一个包含5个值的对象。 Then you would create an list of those objects (that way the values are all linked). 然后,您将创建这些对象的列表(这样,值将全部链接在一起)。

Then you would just do: 然后,您将要做:

OBJECT.Sort(Function(x, y) x.valueToSortBy.CompareTo(y.valueToSortBy))

This would give you a list of your objects sorted by the value you wanted. 这将为您提供按所需值排序的对象列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM