please tell me algorithm or code for following character sorting (Ascending) problem.
For example Text file contains following data:
001, PSTR, abcdef, h.no.222 abcdefghik lmnopq rstuv, student, A-level
002, MKTO, abcdef, house. 2 abcdefghik lmnopq rstuv, student, rtv
003, LORR, abcdef, h.number.210 abcdefghik lmnopq rstuv, student, O-level
005, ASMP, abcdef, h.#.111 abcdefghik lmnopq rstuv, student, mpr
006, SBIL, abcdef, house.no.234abcdefghik lmnopq rstuv, student, h
007, CEGF, seefwd, h. 120 abcdefghik lmnopq rstuv, student, stvdedstg
008, XMEL, decfab, h.no.333 abcdefghik lmnopq rstuv, student, mstvuv
009, BSTU, abcefd, h.no.333 abcdefghik lmnopq rstuv, student, mstvuv
010, ZJRV, defabc, h.no.333 abcdefghik lmnopq rstuv, student, mstvuv
Data is comma separated in the text file. How can i sort in the ascending order on the basis of data that is after first comma for example "PSTR" here.
please tell me using file handling mechanism.
I have done following:
1. used structure to store a string of Key and int line number:
2. extract first number in Integer Line and Column in all object values.
3. Using nested for loop i have done BUBBLE Sort :( . and inserted the sorted sequence in new file.
4. By using nested while loop i have done following:
external loop opens sorted text file first character that is Id. then walks into internal loop which reads line from old file and compares external Id from internal Id if both same than output is shown in the new file.
but this doesn't works fine. it extracts only first 2 records out of 10.
please tell me what should be done here and tell me what should be done when record has many entries (3000 or more) in text file with comma separation.
please tell me easy way to solve the problem.
waiting for reply