unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* sorting backwards?
@ 2005-05-15  3:04 Joe Corneli
  0 siblings, 0 replies; 5+ messages in thread
From: Joe Corneli @ 2005-05-15  3:04 UTC (permalink / 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

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

end of thread, other threads:[~2005-05-17 21:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
2005-05-15  3:04 Joe Corneli

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).