Skip to content

Instantly share code, notes, and snippets.

@carloszan
Last active August 29, 2015 14:17
Show Gist options
  • Save carloszan/df8b2f36efaeab3b4166 to your computer and use it in GitHub Desktop.
Save carloszan/df8b2f36efaeab3b4166 to your computer and use it in GitHub Desktop.
Insertion Sort - C++
template<class T>
void insertion(T *data, int n)
{
T temp; int j=0;
for(int i=1;i<n;i++)
{
temp=data[i];
for(j=i;j>0&&temp<data[j-1];j--)
data[j]=data[j-1];
data[j]=temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment