I am trying to group objects in an array where positive values above, below, left and right would indicate a common group but diagonal would not. See example below.