4.1.10.5.17 SortResponseLinks

 procedure SortResponseLinks(var msgOut: DRS_MSG_GETCHGREPLY_NATIVE)

The SortResponseLinks procedure sorts the contents of msgOut.rgValues in ascending order according to the comparison method CompareLinks():

 procedure CompareLinks(REPLVALINF_NATIVE val1, REPLVALINF_NATIVE val2): integer
 begin
   c: integer
   dsname1: DSName
   dsname2: DSName
  
  
   /* Returns 1
      if val1 > val2, 0 if val1 = val2, or -1 if val1 < val2. */
  
  
   /* Compare by ascending host object objectGUID. */
   c := result of ANSI C function memcmp() 
       applied to val1.pObject^.Guid and val2.pObject^.Guid, 
       in little-endian byte order
  
  
   /* Then by ascending attribute ID. */
   if c = 0 then
     if val1.attrTyp < val2.attrTyp then
       c := -1
     else if val1.attrTyp > val2.attrType then
       c := 1
     endif
   endif
  
  
   /* Then by ascending "is present". */
   if c = 0 then
     if not val1.fIsPresent and val2.fIsPresent then
       c := -1
     else if val1.fIsPresent and not val2.fIsPresent then
       c := 1
     endif
   endif
  
  
   /* Then by ascending referenced object objectGUID. */
   if c = 0 then
     dsname1 := Value of val1.AVal.pVal^
     dsname2 := Value of val2.AVal.pVal^
  
  
     c := result of ANSI C function memcmp() applied to dsname1.Guid
         and dsname2.Guid, in little-endian byte order
   endif
  
  
   return c
 end