Need a strange sort method...
Gerard Flanagan
grflanagan at yahoo.co.uk
Mon Oct 16 16:00:16 EDT 2006
Gerard Flanagan wrote:
> SpreadTooThin wrote:
> > I have a list and I need to do a custom sort on it...
> >
> > for example:
> > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
>
> > 1 4 7 10
> > 2 5 8
> > 3 6 9
> >
>
> from math import sqrt
>
> for i in range(2,12):
> seq = range(1,i)
> numcols = int(sqrt(len(seq)))
> print columnise(seq, numcols)
>
should be:
numcols = int(sqrt(len(seq) + 0.5)
Gerard
More information about the Python-list
mailing list