On-demand string sorting is the problem of preprocessing a set of strings to allow subsequent queries for finding the lexicographically smallest strings (and afterward the next etc.) This on-demand variant strongly resembles the search engine queries which give you the best -ranked pages recurringly.
We present a data structure that supports this in preprocessing time, where is the number of strings, and answer queries in time. There is also a cost of time amortized over all operations, where is the total length of the strings.
Our data structure is a heap of strings, which supports heapify and delete-mins. As it turns out, implementing a full heap with all operations is not that simple. For the sake of completeness, we propose a heap with full operations based on balanced indexing trees that supports the heap operations in optimal times.