This assumes you're making a dynamic 2D array of objects. You could have just as easily went 1D.
#define BUCKETS 750
#define BINS 4000
#define INVALIDBINORBUCKET (BUCKETS*BINS)
#define WHATBUCKET(x) ((x)/BINS)
#define WHATBIN(x) ((x)%BINS)
type put( type**data, type object, type where )
if( where > 0 && where < INVALIDBINORBUCKET )
type bin = WHATBIN( where );
type bucket = WHATBUCKET( where );
data[ bucket ][ bin ] = object;
You may want to place things where you think they should be as you read them in. Take some value, decide where that value should roughly fall, and stick it in that bin/bucket. Then later run through and sort the whole thing (I guess).