On Tuesday, June 24, 2014 7:52:10 AM UTC-5, Axel Bender wrote: > @Ben Fritz > > > > As I see it, you can use a search pattern (r) for certain tasks, but it isn't > a solution. Please, consider the following sample: > > > > 19500623 # ÖST # USA # Curitiba > > 19500621 # ÖST # MEX # Macapa > > 19500825 # AND # FRA # Curitiba > > 19500620 # MEX # BRA # Recife > > 19500625 # BEL # FRA # Curitiba > > > > sort -t# -k4r -k1 sample : Reverse sort on column 4, then sort on column 1 > > > > 19500620 # MEX # BRA # Recife > > 19500621 # ÖST # MEX # Macapa > > 19500623 # ÖST # USA # Curitiba > > 19500625 # BEL # FRA # Curitiba > > 19500825 # AND # FRA # Curitiba > > > > I see no way to accomplish this in vim using :sort (lest you would write a > VimL script).
Ah, so the --key field is a bit smarter than just column (i.e. character number) matching. I was't clear on that. I thought your sort could be done in Vim with 2 passes, but unfortunately it does not work: sort r /^\d\+/ sort! /.*#/ I added another field where I copied the "Macapa" line and changed the 195 to 194 so that I could verify the primary sort (on the last field) actually works, since your example actually could be sorted only on the first field for the same final result. It doesn't work, because "The details about sorting depend on the library function used. There is no guarantee that sorting is 'stable' or obeys the current locale." On my Windows 7 system, apparently the sort is not stable, so multiple sorts cannot be chained together for secondary or ternary sort fields. Bram, is there any possibility of adding multiple sort fields or at least providing the ability to guarantee a "stable" sort? -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
