my Quicksort attempt has failed

I have an array of intergers i need to sort with quicksort. I tried using what is on Wikipedia: en.wikipedia.org/wiki/Quicksort ...but it did not go so well. I am getting Array out of bound errors. And I kind of winged it, so there could be a whole bunch of errors. Dunno.

Code:

` public static int[] quickSort(int[] list)`

{

int[] L = new int[list.length];

int[] G = new int[list.length];

int[] all = new int[list.length];

int lcount, gcount;

lcount = gcount = 0;

if(list.length <= 1)

return list;

int p = list[list.length-1];

for(int i = 0; i < list.length; i++)

{

if(list[i] <= p)

{

L[lcount] = list[i];

lcount++;

}

else

{

G[gcount] = list[i];

gcount++;

}

}

int i = 0;

for(int j = 0; j < lcount; j++)

{

all[i] = L[j];

i++;

}

all[i] = p;

i++;

for(int j = 0; j < gcount; j++)

{

all[i] = G[j];

i++;

}

return all;

}

the main method just makes a bunch of random integers and then displays them after calling this method

the way i did it seems kind of messy... but i'm having difficulty doing it with an array. please help