Worst case, you'll have to sort it yourself again to get "the specific sort order" you're looking for.
So, i decided to follow your advice, and got a little bit carried away while doing that: instead of doing reasonable thing, deleting some porn and running ordinary 'sort' on the file, i decided to write my own script that will re-sort the whole list in-place.
That script is available here:
http://femtocat.ru/bigbeautifulsorter.pyJust run it like this:
python3 bigbeautifulsorter.py all_Bitcoin_addresses_ever_used_sorted.txt.gz
and it
should, after a while, 'repair' this file, making it so that it that passes the 'sort -k' check and is also ~1.8 Gb smaller. While doing that, it will consume ~100Mb of RAM.
Here is the output of /usr/bin/time --verbose i got during the last run:
Command being timed: "python3.10 /home/femtocat/yolotrum/bigbeautifulsorter.py all_Bitcoin_addresses_ever_used_sorted.txt.gz"
User time (seconds): 15464.49
System time (seconds): 112.53
Percent of CPU this job got: 91%
Elapsed (wall clock) time (h:mm:ss or m:ss): 4:44:23
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 96296
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 13228792
Voluntary context switches: 51772
Involuntary context switches: 233986
Swaps: 0
File system inputs: 144586448
File system outputs: 185097296
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
There are a few obvious caveats, though:
- 1. Since it modifies the list in-place, any interruption, be it from the power outage or some bug being present in the code, will irreversibly corrupt the file
- 2. It will take a while: as you can see, on my computer it was working for almost 5 hours.
Interestingly enough, limiting factor here seems to be the compression speed, not the IO performance, so it is possible that on a processor better than my ancient E5-2689 it will work faster. - 3. The reason script consumes so little (relatively speaking) RAM is because it shuffles data around on-disk. In other words, the load on your hard drive/sdd will be substantial. Be aware of that.
Important note: script is designed to fix the list of addresses that is already mostly sorted. Trying to use it on the list that is not will almost certainly cause it to eat all the memory, crash and
corrupt the file it was working on.