<s>
Bead	B-Algorithm
sort	I-Algorithm
,	O
also	O
called	O
gravity	B-Algorithm
sort	I-Algorithm
,	O
is	O
a	O
natural	O
sorting	B-Algorithm
algorithm	I-Algorithm
,	O
developed	O
by	O
Joshua	O
J	O
.	O
Arulanandham	O
,	O
Cristian	O
S	O
.	O
Calude	O
and	O
Michael	O
J	O
.	O
Dinneen	O
in	O
2002	O
,	O
and	O
published	O
in	O
The	O
Bulletin	O
of	O
the	O
European	O
Association	O
for	O
Theoretical	O
Computer	O
Science	O
.	O
</s>
<s>
Both	O
digital	B-General_Concept
and	O
analog	O
hardware	O
implementations	O
of	O
bead	B-Algorithm
sort	I-Algorithm
can	O
achieve	O
a	O
sorting	B-Algorithm
time	O
of	O
O(n )	O
;	O
however	O
,	O
the	O
implementation	O
of	O
this	O
algorithm	O
tends	O
to	O
be	O
significantly	O
slower	O
in	O
software	O
and	O
can	O
only	O
be	O
used	O
to	O
sort	O
lists	O
of	O
positive	O
integers	O
.	O
</s>
<s>
The	O
bead	B-Algorithm
sort	I-Algorithm
operation	O
can	O
be	O
compared	O
to	O
the	O
manner	O
in	O
which	O
beads	O
slide	O
on	O
parallel	O
poles	O
,	O
such	O
as	O
on	O
an	O
abacus	B-Application
.	O
</s>
<s>
The	O
mechanism	O
underlying	O
bead	B-Algorithm
sort	I-Algorithm
is	O
similar	O
to	O
that	O
behind	O
counting	B-Algorithm
sort	I-Algorithm
;	O
the	O
number	O
of	O
beads	O
on	O
each	O
pole	O
corresponds	O
to	O
the	O
number	O
of	O
elements	O
with	O
value	O
equal	O
or	O
greater	O
than	O
the	O
index	O
of	O
that	O
pole	O
.	O
</s>
<s>
Bead	B-Algorithm
sort	I-Algorithm
can	O
be	O
implemented	O
with	O
four	O
general	O
levels	O
of	O
complexity	O
,	O
among	O
others	O
:	O
</s>
<s>
This	O
is	O
the	O
case	O
used	O
in	O
the	O
analog	O
and	O
digital	B-General_Concept
hardware	O
solutions	O
.	O
</s>
<s>
This	O
is	O
the	O
case	O
when	O
bead	B-Algorithm
sort	I-Algorithm
is	O
implemented	O
without	O
a	O
mechanism	O
to	O
assist	O
in	O
finding	O
empty	O
spaces	O
below	O
the	O
beads	O
,	O
such	O
as	O
in	O
software	O
implementations	O
.	O
</s>
<s>
Like	O
the	O
Pigeonhole	B-Algorithm
sort	I-Algorithm
,	O
bead	B-Algorithm
sort	I-Algorithm
is	O
unusual	O
in	O
that	O
in	O
worst	O
case	O
it	O
can	O
perform	O
faster	O
than	O
O(n log n )	O
,	O
the	O
fastest	O
performance	O
possible	O
for	O
a	O
comparison	B-Algorithm
sort	I-Algorithm
in	O
worst	O
case	O
.	O
</s>
<s>
This	O
is	O
possible	O
because	O
the	O
key	O
for	O
a	O
bead	B-Algorithm
sort	I-Algorithm
is	O
always	O
a	O
positive	O
integer	O
and	O
bead	B-Algorithm
sort	I-Algorithm
exploits	O
its	O
structure	O
.	O
</s>
<s>
This	O
implementation	O
is	O
written	O
in	O
the	O
Python	B-Language
;	O
it	O
is	O
assumed	O
that	O
the	O
will	O
be	O
a	O
sequence	O
of	O
integers	O
.	O
</s>
<s>
We	O
can	O
also	O
implement	O
the	O
algorithm	O
using	O
Java	B-Language
.	O
</s>
