lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



I can probably create my own sorted iterator spairs() that will pre-sort the keys in some way. It can be smart to handle multiple types, like a mix of strings and numbers, even some types of user data if those can be ordered deterministically. It will not be very fast but I don't expect to use it for more than a few dozen items.

In fact if the number of items is quite small I can do the sorting directly in the the iterator's stack, and not even bother creating a separate table to hold the order.

Yes, this is a familiar train of thought :)  I posted C-code for such a non-allocating spairs a few months back, under the list post "adventures with iterators".

-Sven