<s>
Pigeonhole	O
sorting	B-Algorithm
is	O
a	O
sorting	B-Algorithm
algorithm	I-Algorithm
that	O
is	O
suitable	O
for	O
sorting	B-Algorithm
lists	O
of	O
elements	O
where	O
the	O
number	O
n	O
of	O
elements	O
and	O
the	O
length	O
N	O
of	O
the	O
range	O
of	O
possible	O
key	O
values	O
are	O
approximately	O
the	O
same	O
.	O
</s>
<s>
It	O
is	O
similar	O
to	O
counting	B-Algorithm
sort	I-Algorithm
,	O
but	O
differs	O
in	O
that	O
it	O
"	O
moves	O
items	O
twice	O
:	O
once	O
to	O
the	O
bucket	O
array	B-Data_Structure
and	O
again	O
to	O
the	O
final	O
destination	O
 [ whereas ] 	O
counting	B-Algorithm
sort	I-Algorithm
builds	O
an	O
auxiliary	O
array	B-Data_Structure
then	O
uses	O
the	O
array	B-Data_Structure
to	O
compute	O
each	O
item	O
's	O
final	O
destination	O
and	O
move	O
the	O
item	O
there.	O
"	O
</s>
<s>
Given	O
an	O
array	B-Data_Structure
of	O
values	O
to	O
be	O
sorted	O
,	O
set	O
up	O
an	O
auxiliary	O
array	B-Data_Structure
of	O
initially	O
empty	O
"	O
pigeonholes	O
"	O
,	O
one	O
pigeonhole	O
for	O
each	O
key	O
in	O
the	O
range	O
of	O
the	O
keys	O
in	O
the	O
original	O
array	B-Data_Structure
.	O
</s>
<s>
Going	O
over	O
the	O
original	O
array	B-Data_Structure
,	O
put	O
each	O
value	O
into	O
the	O
pigeonhole	O
corresponding	O
to	O
its	O
key	O
,	O
such	O
that	O
each	O
pigeonhole	O
eventually	O
contains	O
a	O
list	O
of	O
all	O
values	O
with	O
that	O
key	O
.	O
</s>
<s>
Iterate	O
over	O
the	O
pigeonhole	O
array	B-Data_Structure
in	O
increasing	O
order	O
of	O
keys	O
,	O
and	O
for	O
each	O
pigeonhole	O
,	O
put	O
its	O
elements	O
into	O
the	O
original	O
array	B-Data_Structure
in	O
increasing	O
order	O
.	O
</s>
