As we all know the sort method the array works upon. The speed is affected by the number of items stored in an array. However would the speed be affected by the size of the individual items? I searched this over the net but i haven't found a convincing answer. Anybody got helpful links or explanation that can be displayed here?
For example we can have an array storing 100 string items which are all 20 string characters in length. Would the speed of sorting differ with 100 string items which are all 30 string characters?
Thank you
Would the speed of sorting differ with 100 string items which are all 30 string characters?
Potentially, yes. Potentially, no. It depends. If you have a bunch of strings which only differ at character 30, that will take longer to sort than a bunch of strings which only differ at character 20 - simply because each string comparison will have more work to do. On the other hand, if you have a bunch of strings which differ in their first characters, then the comparisons will be quick no matter how many trailing characters there are.
Also note that the more data you're using, the less effective the CPU cache may be, which can make a huge difference.
See more on this question at Stackoverflow