Is there a reason why you're not just using sequence numbers? Something like this:
alias news_init {
hmake news 10
set %news.lb 1
set %news.ub 1
}
alias news_addentry {
inc %news.ub
hadd news %news.ub $ctime $1- (whatever you want to enter)
}
alias news_remove_oldest_entry {
hdel news %news.lb
inc %news.lb
}
alias news_list {
var %k = %news.lb
while (%k <= %n) {
var %news = $hget(news,%k)
echo @newswindow Time: $gettok(%news,1,32) Text: $gettok(%news,2-,32)
inc %k
}
}
No need to sort stuff each time you need to send or display the news items. Only bad points: putting a news item in between is not easy (requires all following news entries to be moved) and searching on $ctime is somewhat more time-consuming, use $hfind(news,$ctime *,1,w).data to get the correct sequence number.
I've used global %variables for lower and upper bound, you can also put them in the hash table itself ofcourse...