-7

我需要对一个字符串数组进行排序,如下所示。

<MP:F> SG10.01,"SG1 ANTA H 2300 MHz Mod",#.##," dB",LIM,23.00,34.00
<DATA> GEN_FREQ,2300e6,,MESSAGE,"Action: Connect the external PM power sensor to ANT A via N->7/16 adapter.",,DELAY,1000,,PICTURE,ANTA_PM.JPG
<MP:F> SG10.02,"SG1 to ANTA H 2302.5 MHz Mod",#.##," dB",LIM,23.00,34.00<DATA> GEN_FREQ,2302.5e6
<MP:F> SG10.03,"SG1 to ANTA H 2305.0 MHz Mod",#.##," dB",LIM,23.00,34.00<DATA> GEN_FREQ,2305.0e6
<MP:F> SG10.04,"SG1 to ANTA H 2380 MHz Mod",#.##," dB",LIM,23.00,34.00<DATA> GEN_FREQ,2380e6
<MP:F> SG10.05,"SG1 to ANTA H 2385 MHz Mod",#.##," dB",LIM,23.00,34.00<DATA> GEN_FREQ,2385e6
<MP:F> SG10.06,"SG1 to ANTA H 2390 MHz Mod",#.##," dB",LIM,23.00,34.00<DATA> GEN_FREQ,2390e6
<MP:F> SG10.07,"SG1 to ANTA H 2392.5 MHz Mod",#.##," dB",LIM,23.00,34.00<DATA> GEN_FREQ,2392.5e6

排序是按照频点的编号排序的,排序完成后会重新排列索引号吗?

我该怎么办?

4

2 回答 2

2

我建议如下:

  • 将每一行解析成相应的数据结构(结构或对象,你喜欢)
  • 将每个对象插入List<T>
  • 在想要的字段上使用 LINQ 对列表进行排序
  • 将有序的值输出到数组
于 2012-09-06T09:00:31.820 回答
0
  1. 编写一个例程从每个记录中解析所需的排序条件(频率点),
  2. 创建一个字典,一方面你得到解析的频率点,另一方面得到整个字符串,
  3. 根据 GEN_FREQ对 Dictionary 进行排序,并以新的顺序重新排列所有字符串。
于 2012-09-06T08:59:32.380 回答