C++ Implementation
This is a generic implementation mimicking the C++ Standard Library's sort function template. The deliberate limitation of BidirectionalIterator's operations to increment (++), decrement (--) and not equal (!=), is to ensure that the function template will work identically for: C arrays, C++11 arrays, deques, lists and vectors.
#includeRead more about this topic: Gnome Sort