Commit e2e63555 authored by KALPIT VEERWAL's avatar KALPIT VEERWAL

change implementation to insertion-sort

parent 4150af66
#include "sorting.h"
vector<int> sort_custom(vector<int> inp){
for (int i=0;i<inp.size();i++){
for (int j=1;j<inp.size();j++){
if (inp[j-1]>inp[j]){
int temp=inp[j];
int i, key, j;
for (i = 1; i < inp.size(); i++)
key = inp[i];
j = i-1;
while (j >= 0 && inp[j] > key)
inp[j+1] = inp[j];
j = j-1;
inp[j+1] = key;
return inp;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment