unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Joe Corneli <jcorneli@math.utexas.edu>
Subject: sorting backwards?
Date: Sat, 14 May 2005 22:04:48 -0500	[thread overview]
Message-ID: <E1DX9Qu-0006K6-00@lab2.ma.utexas.edu> (raw)


I just posted some code on gnu-emacs-sources that includes some
sorting.  I want to get numbers in decreasing order, but I found that
substituting a ">" for a "<" when sorting screws things up.  (Lots of
contents are omitted.)

Since both < and > are symmetrical mathematically, I don't see why
this would be.

I don't have a great example to hand you right now, but if you grab
the fr3q.el code I just posted and substitute, 

  (let (1graphs)
    (maphash (lambda (key val) 
               (setq 1graphs (cons (cons key val) 1graphs)))
             fr3q-1graphs)
    (sort 1graphs (lambda (a b) (> (cdr a) (cdr b)))) ...

for

  (let (1graphs)
    (maphash (lambda (key val) 
               (setq 1graphs (cons (cons key val) 1graphs)))
             fr3q-1graphs)
    (sort 1graphs (lambda (a b) (< (cdr a) (cdr b)))) ...

Maybe you can verify that and/or explain why upon running fr3q-print,
you see something like:

Keys:
/ 1
4 1
2 1
M-v 1
C-/ 1
E 1
M-c 1
( 1
) 1
S 1
A 1
C-  1
M-w 1
C-y 1
insert 1
3 1
C-k 1
> 1
C-M-x 1

instead of (what you expected):

Keys:
o 114
r 84
i 84
u 83
n 80
  74
, 72
a 71
s 59
p 59
e 54
l 49
h 48
g 47
y 43
up 38
down 35
t 33
' 29
c 28
return 25
backspace 20
f 16
d 15
M-f 15
left 11
m 10
; 10
q 9
M-q 9
w 7
v 7
. 6
C-e 6
M-b 6
C-s 6
k 5
M-backspace 5
M-< 5
z 4
b 4
M-> 4
C-left 4
C-l 4
1 3
C-v 3
C-right 3
j 2
x 2
(mouse-1 (#<window 19 on fr3q.el> 561 (398 . 679) 99227077 nil 561 (66 . 13) nil (-64 . 510) (7 . 13))) 2
5 2
C-g 2
I 2
- 2
C-M-x 2
/ 1
4 1
2 1
M-v 1
C-/ 1
E 1
M-c 1
( 1
) 1
S 1
A 1
C-  1
M-w 1
C-y 1
insert 1
3 1
C-k 1
> 1
< 1

             reply	other threads:[~2005-05-15  3:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-15  3:04 Joe Corneli [this message]
     [not found] <mailman.6010.1116126541.2819.help-gnu-emacs@gnu.org>
2005-05-15 10:17 ` sorting backwards? David Kastrup
2005-05-16  6:50   ` Joe Corneli
     [not found]   ` <mailman.65.1116356089.25862.help-gnu-emacs@gnu.org>
2005-05-17 21:52     ` David Kastrup
2005-05-15 10:56 ` Thien-Thi Nguyen

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1DX9Qu-0006K6-00@lab2.ma.utexas.edu \
    --to=jcorneli@math.utexas.edu \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).