Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
075a171e
Commit
075a171e
authored
Mar 10, 2017
by
Stephane Glondu
Browse files
Change ordering of hashes in pretty_ballots page
parent
a519be8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/common.ml
View file @
075a171e
...
...
@@ -150,4 +150,19 @@ let save_to filename writer x =
Bi_outbuf
.
flush_channel_writer
ob
;
close_out
oc
;;
let
b64_order
=
"+/0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
let
compare_b64
a
b
=
let
na
=
String
.
length
a
and
nb
=
String
.
length
b
in
let
value_of
c
=
try
String
.
index
b64_order
c
with
Not_found
->
-
1
in
let
rec
loop
i
=
match
(
i
<
na
)
,
(
i
<
nb
)
with
|
true
,
true
->
let
diff
=
value_of
a
.
[
i
]
-
value_of
b
.
[
i
]
in
if
diff
=
0
then
loop
(
i
+
1
)
else
diff
|
true
,
false
->
1
|
false
,
true
->
-
1
|
false
,
false
->
0
in
loop
0
module
SMap
=
Map
.
Make
(
String
)
src/lib/common.mli
View file @
075a171e
...
...
@@ -53,4 +53,6 @@ val option_map : ('a -> 'b) -> 'a option -> 'b option
val
save_to
:
string
->
(
Bi_outbuf
.
t
->
'
a
->
unit
)
->
'
a
->
unit
val
compare_b64
:
string
->
string
->
int
module
SMap
:
Map
.
S
with
type
key
=
string
src/web/web_templates.ml
View file @
075a171e
...
...
@@ -1645,9 +1645,7 @@ let pretty_ballots w hashes result () =
let
params
=
W
.
election
.
e_params
in
let
title
=
params
.
e_name
^
" — "
^
L
.
accepted_ballots
in
let
nballots
=
ref
0
in
let
hashes
=
List
.
sort
(
fun
a
b
->
String
.(
compare
(
uppercase
a
)
(
uppercase
b
)))
hashes
in
let
hashes
=
List
.
sort
compare_b64
hashes
in
let
ballots
=
List
.
map
(
fun
h
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment