🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99667

sort-fields

#99667
From: macrakis
Date: Fri, 29 Jun 1990 11:14
49 lines
2619 bytes
GNU Emacs 18.53.11 on NeXT 1.0.1

Some comments on sort functions:

1. MARK BUG

Currently, sort functions move all markers pointing <into> the sorted
region (before the sort) to the beginning of the sorted region (after
the sort).

In particular, the region after the sort no longer contains the sorted
region!  This is terrible!

2. DOCUMENTATION

Current documentation for sort-fields reads:

    Sort lines in region lexicographically by the ARGth field of each line.
    Fields are separated by whitespace and numbered from 1 up.
>>  With a negative arg, sorts by the -ARG'th field, in reverse order.
    Called from a program, there are three arguments:
    FIELD, BEG and END.  BEG and END specify region to sort.

The highlighted line is correct, but, on quick reading, misleading.
You might interpret it to mean that it sorts on the -ARG'th field
counting from the end of the line.

In fact, it means that it sorts on the abs(ARG)'th field.  If ARG is
negative, then the sort is in reverse order.  So I would rewrite the
doc as follows:

    Sort lines in region lexicographically by the abs(ARG)'th field of each line.
    Fields are separated by whitespace and numbered from 1 up.
    If ARG is negative, sort in descending order.
    Called from a program, there are three arguments:
    FIELD, BEG and END.  BEG and END specify region to sort.

Also, ALL sort funtions (except where key=record, like sort-lines)
should have a final line saying "Sort is stable." (this means that if
keys are equal, the original order is preserved).  Quick experiments
show that this is true, but I have not looked at the code to verify
it.  (If it's not true, it should be!)

3. FUNCTIONALITY

Actually, I would find being able to sort on fields counted from the
end much more useful than sorting in reverse.  If there's any demand
for this, I will send in code.  (It's easy enough, given the nice
modularity of sort.el.)
Technical Details
Message-ID: <9006291226.AA01823@.dupuis.gr.osf.org.>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!ns-mx!iowasp!maverick.ksu.ksu.edu!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ri.osf.fr!macrakis

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,c3b5b9ff8daf72c,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-06-29 23:57:31 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!ns-mx!iowasp!maverick.ksu.ksu.edu!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ri.osf.fr!macrakis
From: macrakis@ri.osf.fr
Newsgroups: gnu.emacs.bug
Subject: sort-fields
Message-ID: <9006291226.AA01823@.dupuis.gr.osf.org.>
Date: 29 Jun 90 11:14:32 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 49
Posted: Fri Jun 29 12:14:32 1990
X-Unparsable-Date: Fri, 29 Jun 90 13:26:28 GMT+0100