/****************************************************************************** * test macro to sort two columns ******************************************************************************/ /////////////////////////// // To run it in root: // > .L DoubleSort.C+ // > DoubleSort("table4test.txt") // /////////////////////////// #include #include "TMath.h" #include "TString.h" const Int_t kBufSize = 1024; void DoubleSort(const char *infile, const char *sep = "\t") { ifstream input; input.open(infile, ios::in); if (!input.good()) { cerr << "Error: File does not exist: " << infile << endl; input.close(); return; }//if char nextline[512]; Int_t fN = 9; Int_t *x = new Int_t[fN]; Int_t *y = new Int_t[fN]; Long64_t *w = new Long64_t[fN]; //? Long64_t *fIndex = new Long64_t[fN]; Int_t *fIndex = new Int_t[fN]; Int_t idx = 0; while (input.good()) { input.getline(nextline, kBufSize, '\n'); if (input.eof()) break; x[idx] = atoi(strtok(&nextline[0], sep)); y[idx] = atoi(strtok(0, sep)); Long64_t majorv = (Long64_t)x[idx]; Long64_t minorv = (Long64_t)y[idx]; w[idx] = majorv << 31; w[idx] += minorv; cout << "x = " << majorv << " y = " << minorv << " w[i] = " << w[idx] << endl; idx++; }//while TMath::Sort(fN, w, fIndex, 0); for (Int_t i=0; i