Skip to content

Instantly share code, notes, and snippets.

@copy
Created January 29, 2015 16:52
Show Gist options
  • Save copy/8ef2af76f636fa648c72 to your computer and use it in GitHub Desktop.
Save copy/8ef2af76f636fa648c72 to your computer and use it in GitHub Desktop.
function swap(arr, i, j)
{
var t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
function sorty(arr)
{
var end = arr.length - 1;
var start = 0;
while(start < end)
{
if(arr[start] >= 0)
{
while(start < end && arr[end] >= 0)
{
end--;
}
if(start < end)
{
swap(arr, start, end);
}
}
if(start < end)
{
start++;
}
}
end = arr.length - 1;
while(start < end)
{
if(arr[start] > 0)
{
while(start < end && arr[end] > 0)
{
end--;
}
if(start < end)
{
swap(arr, start, end);
}
}
if(start < end)
{
start++;
}
}
return arr;
}
@eeveeta
Copy link

eeveeta commented Jan 30, 2015

hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment