ideas for algorithm? sorting a list randomly with emphasis on variety

Posted by Steve Eisner on Stack Overflow See other posts from Stack Overflow or by Steve Eisner
Published on 2010-03-20T18:18:51Z Indexed on 2010/03/20 18:21 UTC
Read the original article Hit count: 296

I have a table of items with [ID,ATTR1,ATTR2,ATTR3]. I'd like to select about half of the items, but try to get a random result set that is NOT clustered. In other words, there's a fairly even spread of ATTR1 values, ATTR2 values, and ATTR3 values. This does NOT necessarily represent the data as a whole, in other words, the total table may be generally concentrated on certain attribute values, but I'd like to select a subset with more variety. The attributes are not inter-related, so there's not really a correlation between ATTR1 and ATTR2.

Any ideas for an efficient algorithm? Thanks! I don't really even know how to search for this :)

© Stack Overflow or respective owner

Related posts about random

Related posts about sorting