-7

I need to sort a string array like below.

<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

The sort follow the number of the frequency point and when i finish the sort, i will rearrang the index number?

How could i do?

Dor Cohen
  • 15,873
  • 22
  • 85
  • 152
WENGHui
  • 11
  • I want to use the regular expression to find all the frequency point form the date and compare the frequency point then array each line follow the frequency point. – WENGHui Sep 10 '12 at 14:50
  • 1
    That's not an answer to my question. You should show what you have tried so far to demonstrate that you have put some effort in this. – Daniel Hilgarth Sep 10 '12 at 15:12

2 Answers2

2

I suggest the following:

  • Parse each line into a corresponding data structure (struct or object to your liking)
  • Insert each object into a List<T>
  • Order the list using LINQ on the wanted field
  • Output the values of the ordered to the array
Oded
  • 463,167
  • 92
  • 837
  • 979
0
  1. Write a routine to parse from each record the desired sort creteria (frequency point),
  2. Create a Dictionary where you get the parsed frequency point on one hand and the entire strign on the other,
  3. Sort the Dictionary according to the GEN_FREQ and rearrange all string together in the new order.
Community
  • 1
  • 1
CloudyMarble
  • 34,949
  • 69
  • 92
  • 126