From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Need help with sort function for tabulated-list-format Date: Fri, 26 Aug 2022 20:28:48 +0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13556"; mail-complaints-to="usenet@ciao.gmane.io" To: Help GNU Emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 26 19:33:18 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oRdCn-0003Hc-6I for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Aug 2022 19:33:17 +0200 Original-Received: from localhost ([::1]:44750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRdCl-0004et-Om for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Aug 2022 13:33:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRd9N-0004Zd-K0 for help-gnu-emacs@gnu.org; Fri, 26 Aug 2022 13:29:45 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:42211) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRd9L-0003Nj-0t for help-gnu-emacs@gnu.org; Fri, 26 Aug 2022 13:29:44 -0400 Original-Received: from localhost ([::ffff:197.239.4.206]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000B5B12.00000000630902E4.00000CB9; Fri, 26 Aug 2022 10:29:07 -0700 Received-SPF: pass client-ip=217.170.207.13; envelope-from=support1@rcdrun.com; helo=stw1.rcdrun.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_SBL=0.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_DBL_SPAM=2.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:139110 Archived-At: 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/