コード例 #1
0
        public static int ComparebyDistance(MobileServiceOrgUnitDto dto1, MobileServiceOrgUnitDto dto2)
        {
            //If both have invalid distance then compare by name, if either of one is invalid move it to the last
            if (dto1.Distance == 0 && dto2.Distance == 0)
                return ComparebyName(dto1, dto2);

            if (dto1.Distance == 0 && dto2.Distance > 0)
                return 1;

            if (dto1.Distance > 0 && dto2.Distance == 0)
                return -1;

            //If same distance then sort by name
            if (dto1.Distance > 0 && dto2.Distance > 0 && dto1.Distance == dto2.Distance)
                return ComparebyName(dto1, dto2);

            return dto1.Distance.CompareTo(dto2.Distance);
        }
コード例 #2
0
 public static int ComparebyName(MobileServiceOrgUnitDto dto1, MobileServiceOrgUnitDto dto2)
 {
     return String.Compare(dto1.ServiceName, dto2.ServiceName, StringComparison.OrdinalIgnoreCase);
 }