You can never sort less than O (N), because you need to look at all N elements to determine if the list is sorted - so O (N) is right there. You can also sort faster than O (NlogN) if you sort by comparing with other items in your list, but if you know something about your data, you can. If, for example, you know that your data is English strings, you can put them in buckets before sorting. for example, put all the lines, starting from A in one bucket, from B to another, etc. It will be fast. You may need to make each bucket quite large, although perhaps large enough to fit 1000 lines, since not all buckets will contain the same number of lines.
Then sort the individual buckets that will be fast.
(.. 400 , , , , ), , O (N) + O (Nlog N/M), M - .
, , , , , , . , , , .
, .