**It is bit difficult to give exact algorithm for this problem but Just for reference you can refer following solution-**

**binpackFFd(S,n,bin)
** float[] used = new float[n + 1];
//used[j] is the amount of space in bin j already used up.
int i, j;
//Initialize all used entries to 0.0
//Sort S into descending(nonincreasing)order, giving the sequence S1 >= S2 >= ... >= Sn.
for(i = 1; i <= n; i++)
//Look for a bin in which s[i] fits.
for(j = 1; j <= n; j++)
if (used[j] + S[i] <= 1.0) {
bin[i] = j;
used[j] += S[i];
break; //exit for(j)
}

except this refer these links for information-

http://en.wikipedia.org/wiki/Bin_packing_problem

http://www.grasshopper3d.com/forum/topics/packrat-3d-bin-packing

http://chinmaylokesh.wordpress.com/2011/02/20/bin-packing-problem-combinatorial-np-hard-problem/