all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Need help with sort function for tabulated-list-format
@ 2022-08-26 17:28 Jean Louis
  2022-08-26 17:50 ` [SOLVED] " Jean Louis
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Louis @ 2022-08-26 17:28 UTC (permalink / raw)
  To: Help GNU Emacs

In my extensive tabulated list work, usually I use the ID number as
the first column. The ID number, while number in reality, it is
string.

That would mean that I would need to make a function that converts
strings to numbers before sorting such.

And here below there is explanation that SORT shall represent
predicate to `sort' function.

 -- Variable: tabulated-list-format
     This buffer-local variable specifies the format of the Tabulated
     List data.  Its value should be a vector.  Each element of the
     vector represents a data column, and should be a list ‘(NAME WIDTH
     SORT)’, where

        • NAME is the column’s name (a string).

        • WIDTH is the width to reserve for the column (an integer).
          This is meaningless for the last column, which runs to the end
          of each line.

        • SORT specifies how to sort entries by the column.  If ‘nil’,
          the column cannot be used for sorting.  If ‘t’, the column is
          sorted by comparing string values.  Otherwise, this should be
          a predicate function for ‘sort’ (*note Rearrangement::), which
          accepts two arguments with the same form as the elements of
          ‘tabulated-list-entries’ (see below).


Here is my tabulated-list-format:

(defvar cf-people-tabulated-format-with-account [("ID" 8 t) ("Name" 40 t) ("Account" 40 t)])

I would like to provide the mentioned predicate here, something like:

(defvar cf-people-tabulated-format-with-account [("ID" 8 string-as-number-is-smaller-than) ("Name" 40 t) ("Account" 40 t)])

Purpose is to sort the first column by its number represented as string.

 320193   Qg
 328635   Sgh
 334546   Tbrich
 338532   jnet
 347050   ygmail.com
 347886   Tsimmons
 360982   mail.com
 361677   D

Does anybody have sample predicate function for `sort' which accepts
two arguments as the elements of `tabulated-list-entries'?



Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-29  8:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2022-08-27  4:22       ` Emanuel Berg
2022-08-29  8:01         ` Jean Louis

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.