The hardest part of what you are asking is how to actually define proximity. What would you expect the output to be from [5,10,15,20]
? Would it be the same groupings as for [500,1000,1500,2000]
?
What about [1,2,3,5,7,8,9]
? Should there be one group or three? (or two?).
What about [1,2,3,5,7,8,9,1075,4000]
? Do 1075 and 4000 become grouped together? Does the groupings of the smaller numbers become changed by the larger numbers in the sample?
This question is something asked by an entire field of Machine Learning: Cluster Analysis
Perhaps this related question will help?
I think what you want is K-means clustering (helpfully linked to in the related question), but you need to know how many groups you want to split your data into to use it.