Commit 11019fe9 authored by Neeraj Kerkar's avatar Neeraj Kerkar

changed implementation to insertion-sort

parent bbf91dfe
...@@ -2,22 +2,21 @@ ...@@ -2,22 +2,21 @@
using namespace std; using namespace std;
vector<int> sort_custom(vector<int> a) vector<int> sort_custom(vector<int> array){
{ unsigned int i, j;
bool swapp = true; vector<int> sortedArray;
while(swapp) int max;
{
swapp = false; for(i = 0; i<array.size();i++){
for (int i = 0; i < a.size()-1; i++) max = array[i];
{
if (a[i]>a[i+1] ) for(j = i; j<array.size();j++){
{ max = array[j] > max ? array[j]:max;
a[i] += a[i+1];
a[i+1] = a[i] - a[i+1];
a[i] -=a[i+1];
swapp = true;
}
} }
sortedArray[i] = max;
} }
return a;
return sortedArray;
} }
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