Is there a way to modify the bubble sort algorithm so that it will stop as soon as it recognizes that the list is sorted?

If it completes one pass thru the data without having swapped any elements, then the list is sorted, so all you need is a simple boolean for that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.