If I had a dataset such as:
s={{1,1.1,1},{2,1.2,2},{1,2.3,1},{3,2.2,2},{1,3.5,1},{4,3.6,2},{1,4.2,3},{2,4.4,1}}
I want to gather sublists based on the 2nd term of each sublist, such that first group has 2nd term of each sublists between 0 and 2, the second group has 2nd term of each sublists between 2 and 3.7, the third group has 2nd term of each sublists between 3.7 and 5. My output should look like this:
output:= {{{1,1.1,1},{2,1.2,2}},{{1,2.3,1},{3,2.2,2},{1,3.5,1},{4,3.6,2}},{{1,4.2,3},{2,4.4,1}}}
I suspect it should be something of the sort:
r = {0, 2, 3.7, 5};
GatherBy[s, {#[[2]] > #1 &, #[[2]] < #2}] & /@ MapThread[Most@r, Rest@r]
GatherBy[s, #[[2]] < 2.5 &]
does what you want. Can you provide an example for which that fails so that we have a better idea of what you're trying to do? $\endgroup$