Assume we have an string array str = ["foo", "bar", "zebras", "topper"] which I need to to sort to get ["bar", "foo", "zebra", "top"], the sorting complexity will be O(nlogn) where n is the length of the array. But we also do string compare, which should be O(m) where m is the length of longest strings (such as zebras and topper). So final complexity should be O(m * nlogn). Please correct me if I am wrong.
This question differs from here because, here I am comparing all strings with all strings, rather than a fixed string with just one.