If I'm sorting a given dataset, the length of each item does not depend on the number of items. If I'm sorting 32bit integers, my integers are 32 bits if I'm sorting 10,000 of them, and 32 bits if I'm sorting 1,000,000 of them. If I'm sorting dictionary words, the average length of a word is the same if I'm sorting 100 or a billion. The two variables are totally independent.
And in most situations, the length of the terms is constant, and the runtime of the algorithm varies only according to input size, so it can be expressed (in those situations) as O(n). |