[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sorting backwards?
From: |
Joe Corneli |
Subject: |
sorting backwards? |
Date: |
Sat, 14 May 2005 22:04:48 -0500 |
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