How to compare the current result with previous line result.?

Hi Gurus,
I have requirement to compare current result with previous reuslt.
The sample case is below.

 
1   job1    1
1   job2    2
1   job3    3
2   job_a1  1
2   job_a2  2
2   job_a3  3
3   job_b1  1
3   job_b2  2

for above sample file, GID is group ID, for input line, the job run same function and get result.
for same group, I have to compare current job result the previous jobs result (just one line back).
my curernt scrip logic like below:

 
 
while loop
do 
if order=1 (group 1) then
job1_result> temp_gid1.txt
if order <>1 then
job2_result compare temp_gid1.txt and log to output file
job2_result> temp_gid1.txt
job3_result compare temp_gid1.txt and log to output file
 
if order=1 (new group) then
job1_result> temp_gid2.txt
if order <>1 then
job2_result compare temp_gid1.txt and log to output file
job2_result> temp_gid2.txt
job3_result compare temp_gid1.txt and log to output file

above logic works, but it looks very stupid. I want to put the result in ARRAY then compare the current result with ARRAR, but I am not able to figure our how to compare the current result with previous ARRAY.
another problem I have is: I don't know how to use GID to identify the group changing. so I added column ORDER to identified the new group.

Could anybody give me some help.

thanks in advance.

When using a single array, you can check the current entry with the previous index.
So you fill your array, and check the current value vs the current index - 1.

Regarding the ORDER, one could use grep .
However, awk could be alot more usefull if you know how.

hth