need help in writing a comparison shell script

I have a folder a1 with the following files

sample_1.log
sample_2.log
sample_3.log
sample_4.log
sample_5.log
sample_6.log

In another folder there is a file b with the value 5

My script should take the value 5 ( file b), compare it with the files in folder a1, if file name contains the number less than 5, the files in a1 should be deleted.

output should be - sample_1, sample_2, sample_3, sample_4 files deleted.

Kindly help.......

#!/bin/ksh 
# Generic for all posix shells

read value < valuefile
for f in sample_*.log
do
     # remove sample_ and .log
     id=${f/sample_/}
     id=${id/.log/}
     (( id >= value )) && continue
     echo "rm -f $f"
done