Hi frnz,

i want to know which is the fastest algorithm for to sort the text file of 1MB , 10MB , 50MB .


Thanks in advance

String[] lines = File.ReadAllLine("filename");
Array.Sort(lines);
File.WriteAllLines("filename", lines);

50 MB is nothing to a modern computer. In memory sorting will be faster than anything else. As a test I created a 54 MB file consisting of 1,470,588 strings. It took 1.729 seconds to read the file, 17.487 seconds to sort it and 0.690 seconds to write the file back to the disk.

String[] lines = File.ReadAllLine("filename");
Array.Sort(lines);
File.WriteAllLines("filename", lines);

50 MB is nothing to a modern computer. In memory sorting will be faster than anything else. As a test I created a 54 MB file consisting of 1,470,588 strings. It took 1.729 seconds to read the file, 17.487 seconds to sort it and 0.690 seconds to write the file back to the disk.

Hi can you plz , give me the code for to calculate the time it take for to read , write and for to sort and also i want to know which sorting algorithm is fastest e.g bubble sort, merger sort, quick sort, heap sort etc.

thanks buddy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.