Help with korn shell script to get the latest file versions in a directory

I want to write a korn shell script to get the latest three versions for a file in the directory having lot of files with various versions (files with prefix as same but time stamp as suffix) and compress it and at the same time have to remove the remaining versions of the file (other than latest three versions of the file).
I'm new to korn shell scripting. can any one provide me with solution...
the directory structure is like this :

abcd.11122013.txt
abcd.12122013.txt
abcd.10122013.txt
abcd.09122013.txt
xyz.11122013.txt
xyz.12122013.txt
xyz.10122013.txt
......................

In this i want the latest 3 version of files starting with abcd* as prefix. similarly files starting with xyz*.
Help me!

This will show the three most recently modified:

ls -t abcd.*.txt | head -n 3

Or would you rather be sorted by the DDMMYYYY in the filename?

That would be something like:

printf "%s\n" abcd.*.txt | sort -t. -k 2.5,2.8 -k 2.3,2.5 -k 2.1,2.3 | head -n 3

can i get any approach like keeping the required set of prefix files in array and looping in korn shell. because I have different set of files with different prefixes. i want to get the latest 3 files per prefix and archive those.

It's possible with for X in $( whatever ) but often a solution in search of a problem. Putting them in a loop like that forces you to program a certain way.

Archive them how? And which do you want -- the most recently modified or the most recent names? If most recently modified works, archiving is a one-liner:

ls -t abcd.*.txt | head -n 3 | xargs tar -zcf backup-file-name.tar.gz