Python, get neighboring objects on an axis
Did not test this yet:

import bpy

COL_COUNT =  8 # number of columns
ROW_COUNT = 12 # number of rows

objects = bpy.data.groups['group_name'].objects[:]

# no cmp function
# use round to circumvent floating point precision errors
key_x = lambda o: round(o.location.x, 2)
key_y = lambda o: round(o.location.y, 2)

objects.sort(key=key_y, reversed=True) # from top to bottom
objects.sort(key=key_x)

for i, obj in enumerate(objects):
    col = i  % COL_COUNT
    row = i // COL_COUNT

    #do something with obj


See Sorting HOW TO from the official documetation for more information. The most relevant part is:


  Sorts are guaranteed to be stable. That means that when multiple records have the same key, their original order is preserved.


To retrieve the object for a given row and column calculate the index:

index = row * COL_COUNT + col
obj = objects[index]


I.e. for ROW_COUNT = 2 and COL_COUNT = 4 the objects are tagged like this:

0 1 2 3 
4 5 6 7


For the second row and the third column the index is 1 * 4 + 2 = 6. (zero based indices!)