vrothberg/vgrep

Line sort is in alphabetic, not numeric order

Closed this issue · 2 comments

The line number sort is done in 'string' order, not 'numeric' order, which results in output like the following when run in the vgrep repo itself:
$ ./vgrep f | head
Index Source File Source Line Content
0 LICENSE 10 The GNU General Public License is a free, copyleft license for
1 LICENSE 101 a computer network, with no transfer of a copy, is not conveying.
2 LICENSE 103 An interactive user interface displays "Appropriate Legal Notices"
3 LICENSE 105 feature that (1) displays an appropriate copyright notice, and (2)
4 LICENSE 106 tells the user that there is no warranty for the work (except to the
5 LICENSE 108 work under this License, and how to view a copy of this License. If
6 LICENSE 109 the interface presents a list of user commands or options, such as a
7 LICENSE 11 software and other kinds of works.
8 LICENSE 114 The "source code" for a work means the preferred form of the work

I tried to work out how to fix the sort order, but my knowledge of python lamda's is non-existent, so I don't know how to change the following line to do this differently:
return sorted(slocs, key=lambda x: (x.file, x.line))

Thanks, good catch! I am preparing a fix for that.

The following commit fixes the fix to fix it 👯
e2696a7