From: Jean Louis <bugs@gnu.support>
To: help-gnu-emacs@gnu.org
Subject: Re: [SOLVED] Re: Need help with sort function for tabulated-list-format
Date: Sat, 27 Aug 2022 06:39:46 +0300 [thread overview]
Message-ID: <YwmSAvDNGgMkGlcb@protected.localdomain> (raw)
In-Reply-To: <87bks6pza2.fsf@dataswamp.org>
* Emanuel Berg <incal@dataswamp.org> [2022-08-27 06:31]:
> Jean Louis wrote:
>
> > I guess I solved it by looking into the package package
>
> Sort the numeric `sort-numeric-fields' fields.
That function is for sorting lines in region numerically.
While I had to find a function to sort a column within the tabulated
list mode.
Sample value of `tabulated-list-entries':
Value:
((1
["1" ""])
(2
["2" "ACTION"])
(3
["3" "COMPLETED"])
(4
["4" "PENDING"])
(5
["5" "UPDATE PENDING"])
(6
["6" "DECISION REVERSED"]))
That means that this first column with "1", "2", that one has to be
used for sorting. By sorting it as strings, then it goes like "1" "10"
1
2 ACTION
3 COMPLETED
4 PENDING
5 UPDATE PENDING
6 DECISION REVERSED
6 DECISION REVERSED
5 UPDATE PENDING
4 PENDING
3 COMPLETED
2 ACTION
1
Sorting as strings:
(sort '("100" "9" "10" "1") 'string<) ⇒ ("1" "10" "100" "9")
That would be incorrect for numbers, rightß
Tabulated list mode by default sorts columns by its strings.
So I had to make a function that converts strings to numbers, so that
we get something like this:
(sort '(100 9 10 1) '<) ⇒ (1 9 10 100)
Which then makes sense.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
next prev parent reply other threads:[~2022-08-27 3:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 17:28 Need help with sort function for tabulated-list-format Jean Louis
2022-08-26 17:50 ` [SOLVED] " Jean Louis
2022-08-26 19:42 ` Emanuel Berg
2022-08-27 3:39 ` Jean Louis [this message]
2022-08-27 4:22 ` Emanuel Berg
2022-08-29 8:01 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YwmSAvDNGgMkGlcb@protected.localdomain \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.