Sorting filenames by order in another file

I would like to arrange /sort filenames ending with suffix like ".00XXXX". where X is a digit. However the order of arrangement is in a text file and is 'harpharzard'. e.g the text file may be like
002345
009807
001145
I wanted to avoid doing this using sql and exporting the text file back to unix.

to sort a file (file.txt) containing
aaa.002345
bbb.009807
ccc.001145

sort -t "." +1 file.txt > file2.txt

would produce a file (file2.txt) containing
ccc.001145
aaa.002345
bbb.009807

the -t "." specifies that the field delimiter is ".", the +1 tells sort to use the 2nd field. > redirects the output to file2.txt

I do not simply want to sort. I would like to arrange them in an order given in a particular file. Which is NOT necessarily like 123... or abcd...
e.g.
Filenames are a.0011234
d.0023456
h.0032456
b.0025789

and the required order in the (sorting/arranging) file is
0023456
0032456
0011234
0025789

The output file should then be
d.0023456
h.0032456
a.0011234
b.0025789

I know chances are you will need two nested loops.

This works, there may be some better awk/sed ways of doing it, I rarely use them so I'm not sure.

#!/bin/sh
>grepn.out
>linenumbers

cut -c3- file.in > cutfile.in

for record in `cat cutfile.in`
{
grep -n $record file.order >> grepn.out
}
cut -c1 grepn.out >> linenumbers

paste file.in linenumbers > file.tmp

sort +1 file.tmp > file.tmp2

awk '{print $1}' < file.tmp2 > file.out

Thanx Kevin,
Howver even only part of your soln still works well!

grep -n $record file.order >> grepn.out

just replace "-n $record file.order " with "-f file.order"
NOTE grep with the -f option makes a wonderfull loop through a file.

MORE FIRE!