Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Sorting Lists

Name: Anonymous 2012-05-04 17:07

Can you sort a list without loading the entire list into memory?

Name: Anonymous 2012-05-04 17:23

Yes it's possible. You would have to divide the large list into smaller lists and sort through the smaller lists. I would divide the lists into tiers so that sorted values go to a sorted list tier for example, in a list that ranges from 0 1000 of roughly equal distribution, I would divide the list into 10 tiers of 100 and then sort each individual tier.

Name: Anonymous 2012-05-04 17:36

Can you hax an anus without knowing what an anus is?

Name: Anonymous 2012-05-04 18:18

of course

Name: Anonymous 2012-05-04 23:40

If the list is already sorted you don't have to do anything.

Name: Anonymous 2012-05-05 1:18

>>2
But then the entire list is brought into memory, albeit gradually.

Name: Anonymous 2012-05-05 1:24

Thats what they did on mainframes with merge sort and tape drives

Name: Anonymous 2012-05-05 1:27

wait. what?
where will the list come from?

Name: Anonymous 2012-05-05 2:05

>>6
The assumptions we have in that example include:
The whole list is not completely sorted
The whole list needs to be sorted in order
The number of entries in the list are larger than available memory

I wonder how they do things in a relational database. I'm guessing they sort the list by keyfields before storing the entry in the database.

Name: Anonymous 2012-05-05 2:06

Just sort your list in memory.

Name: Anonymous 2012-05-05 3:00

>>10
This. Unless you're doing this as a personal exercise (never a bad idea!). In which case http://en.wikipedia.org/wiki/External_sorting is a decent enough starting point.

Name: bampu pantsu 2012-05-29 4:46

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List