[Gambas-user] Sorting 2D arrays

Fabien Bodard gambas.fr at gmail.com
Mon Aug 24 18:36:50 CEST 2020


More short ;-)



' Gambas class file

Property iKey As Integer Use $iKey
Property sName As String Use $sName
Property sSurName As String Use $sSurName
Property dBirth As Date Use $dBirth

Static Public ForSorting As Integer

Public Sub _new(iKey As Integer, sName As String, sSurName As String,
dBirth As Date)

  $iKey = iKey
  $sName = sName
  $sSurName = sSurName
  $dBirth = dBirth

End


Public Function _compare(hUsers As CUsers) As Integer

  Select ForSorting
    Case 1
      Return Sgn($iKey - hUsers.iKey)
    Case 2
      Return Comp($sName & $sSurName, hUsers.sName & hUsers.sSurName)
    Case 3
      Return Comp($sSurName & $sName, hUsers.sSurName & hUsers.sName)
    Case 4
      Return Sgn(DateDiff($dBirth, hUsers.dBirth, gb.Second))
  End Select

End


More information about the User mailing list