数据表c#在数据表中的复杂排序

时间:2010-12-21 22:44:38

标签: c#

我有一个复杂的数据表,如下所示:

Batch ID    Batch 1 barcode THC     TECAN POS   TECAN ID    Sample Position Sample Name Data File   Method  Sample Type Level Name
Plate ID    1               VIAL1   blank1  D:\MassHunter\data\Batch 1 barcode THC_PAIN\blank1  D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
Plate POS   1               VIAL1   blank2  D:\MassHunter\data\Batch 1 barcode THC_PAIN\blank2  D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            A01 THCCAL1 P1-A01  THCCAL1 D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCCAL1 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 1
            B01 THCCAL2 P1-B01  THCCAL2 D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCCAL2 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 2
            C01 THCCAL3 P1-C01  THCCAL3 D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCCAL3 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 3
            D01 THCCAL4 P1-D01  THCCAL4 D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCCAL4 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 4
            E01 THCQC1  P1-E01  THCQC1  D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCQC1  D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            F01 THCQC2  P1-F01  THCQC2  D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCQC2  D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            G01 THCQC3  P1-G01  THCQC3  D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCQC3  D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            H01 THCQC4  P1-H01  THCQC4  D:\MassHunter\data\Batch 1 barcode THC_PAIN\THCQC4  D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            A02 F862577 P1-A02  F862577 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862577 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            B02 F805357R    P1-B02  F805357R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\F805357R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            C02 N070148R    P1-C02  N070148R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\N070148R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            D02 F862594 P1-D02  F862594 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862594 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            E02 F860417R    P1-E02  F860417R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\F860417R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            F02 F862586 P1-F02  F862586 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862586 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            G02 F862567 P1-G02  F862567 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862567 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            H02 F862582 P1-H02  F862582 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862582 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            A03 F838208R    P1-A03  F838208R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\F838208R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            B03 F760563R    P1-B03  F760563R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\F760563R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            C03 F862580 P1-C03  F862580 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862580 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            D03 F863980R    P1-D03  F863980R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\F863980R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            E03 F715588RC   P1-E03  F715588RC   D:\MassHunter\data\Batch 1 barcode THC_PAIN\F715588RC   D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            F03 N007466 P1-F03  N007466 D:\MassHunter\data\Batch 1 barcode THC_PAIN\N007466 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            G03 F808804R    P1-G03  F808804R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\F808804R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            H03 F945367 P1-H03  F945367 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F945367 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            A04 F862568 P1-A04  F862568 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862568 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            B04 N043919R    P1-B04  N043919R    D:\MassHunter\data\Batch 1 barcode THC_PAIN\N043919R    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            C04 F379160 P1-C04  F379160 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F379160 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            D04 F742173 P1-D04  F742173 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F742173 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            E04 F862574 P1-E04  F862574 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F862574 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            F04 F365407 P1-F04  F365407 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F365407 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            G04 F760668 P1-G04  F760668 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F760668 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            H04 F365408 P1-H04  F365408 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F365408 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            A05 F745746 P1-A05  F745746 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F745746 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  
            B05 F882245 P1-B05  F882245 D:\MassHunter\data\Batch 1 barcode THC_PAIN\F882245 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample  

你可以看到我有几行作为顶部的标题。其余数据按A01,B01,C01,...,A02,B02,...,

排序

但是。我需要在第二栏中挑出所有单词“BLANK”并将它们放在最上面:

Batch ID    16035       TECAN POS   TECAN ID    Sample Position Sample Name Data File   Method  Sample Type Level Name
Plate ID    1               VIAL1   blank1  D:\MassHunter\data\16035_PAIN\blank1    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
Plate POS   1               VIAL1   blank2  D:\MassHunter\data\16035_PAIN\blank2    D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            A01     P1-A01  Calibr_01   D:\MassHunter\data\16035_PAIN\Calibr_01 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 1
            B01     P1-B01  Calibr_02   D:\MassHunter\data\16035_PAIN\Calibr_02 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 2
            C01     P1-C01  Calibr_03   D:\MassHunter\data\16035_PAIN\Calibr_03 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 3
            D01     P1-D01  Calibr_04   D:\MassHunter\data\16035_PAIN\Calibr_04 D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Calibration 4
            E01 QC1 P1-E01  QC1 D:\MassHunter\data\16035_PAIN\QC1   D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            F01 QC2 P1-F01  QC2 D:\MassHunter\data\16035_PAIN\QC2   D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            G01 QC3 P1-G01  QC3 D:\MassHunter\data\16035_PAIN\QC3   D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            H01 QC4 P1-H01  QC4 D:\MassHunter\data\16035_PAIN\QC4   D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            A02 BLANK0031   P1-A02  BLANK0031   D:\MassHunter\data\16035_PAIN\BLANK0031     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            D02 BLANK0028   P1-D02  BLANK0028   D:\MassHunter\data\16035_PAIN\BLANK0028     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            B05 BLANK0026   P1-B05  BLANK0026   D:\MassHunter\data\16035_PAIN\BLANK0026     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            C06 BLANK0025   P1-C06  BLANK0025   D:\MassHunter\data\16035_PAIN\BLANK0025     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            E09 BLANK0027   P1-E09  BLANK0027   D:\MassHunter\data\16035_PAIN\BLANK0027     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            F10 BLANK0029   P1-F10  BLANK0029   D:\MassHunter\data\16035_PAIN\BLANK0029     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            G11 BLANK0030   P1-G11  BLANK0030   D:\MassHunter\data\16035_PAIN\BLANK0030     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            H12 BLANK0032   P1-H12  BLANK0032   D:\MassHunter\data\16035_PAIN\BLANK0032     D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            B02 G085414     P1-B02  G085414     D:\MassHunter\data\16035_PAIN\G085414       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            C02 G085410     P1-C02  G085410     D:\MassHunter\data\16035_PAIN\G085410       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            E02 G143846     P1-E02  G143846     D:\MassHunter\data\16035_PAIN\G143846       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            F02 G085412     P1-F02  G085412     D:\MassHunter\data\16035_PAIN\G085412       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            G02 G215112     P1-G02  G215112     D:\MassHunter\data\16035_PAIN\G215112       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            H02 G143845     P1-H02  G143845     D:\MassHunter\data\16035_PAIN\G143845       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            A03 G085409     P1-A03  G085409     D:\MassHunter\data\16035_PAIN\G085409       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            B03 G143847     P1-B03  G143847     D:\MassHunter\data\16035_PAIN\G143847       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            C03 G143849     P1-C03  G143849     D:\MassHunter\data\16035_PAIN\G143849       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            D03 G071181     P1-D03  G071181     D:\MassHunter\data\16035_PAIN\G071181       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            E03 G143878     P1-E03  G143878     D:\MassHunter\data\16035_PAIN\G143878       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            F03 G071178     P1-F03  G071178     D:\MassHunter\data\16035_PAIN\G071178       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            G03 G071179     P1-G03  G071179     D:\MassHunter\data\16035_PAIN\G071179       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            H03 G071196     P1-H03  G071196     D:\MassHunter\data\16035_PAIN\G071196       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            A04 G202923     P1-A04  G202923     D:\MassHunter\data\16035_PAIN\G202923       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            B04 N169279     P1-B04  N169279     D:\MassHunter\data\16035_PAIN\N169279       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            C04 F961880     P1-C04  F961880     D:\MassHunter\data\16035_PAIN\F961880       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   
            D04 G143844     P1-D04  G143844     D:\MassHunter\data\16035_PAIN\G143844       D:\MassHunter\methods\use_these_methods\PAIN_FINAL.m    Sample   

有谁知道怎么做?任何帮助都会非常感激!

1 个答案:

答案 0 :(得分:1)

停止使用数据表。

使用适当的语义构建一个表示这些值的类。然后使用自定义比较器对对象进行排序。

通过遵循这个建议,你不仅可以解决这个问题,还可以解决接下来的三十五个问题。

并确保你一遍又一遍的实习生字符串以节省内存。

myDataFile.Method = string.Intern((string)reader["Method"]);