public int Compare()

in BluetoothLEExplorer/BluetoothLEExplorer/Models/ObservableBluetoothLEDevice.cs [37:67]


            public int Compare(object x, object y)
            {
                ObservableBluetoothLEDevice a = x as ObservableBluetoothLEDevice;
                ObservableBluetoothLEDevice b = y as ObservableBluetoothLEDevice;

                if( a == null || b == null)
                {
                    throw new InvalidOperationException("Compared objects are not ObservableBluetoothLEDevice");
                }

                // If they're equal sort by bluetooth address
                if(a.RSSI == b.RSSI)
                {
                    return a.BluetoothAddressAsString.CompareTo(b.BluetoothAddressAsString);
                }

                // RSSI == 0 means we don't know it. Always make that the end.
                if(b.RSSI == 0)
                {
                    return -1;
                }

                if(a.RSSI < b.RSSI || a.rssi == 0)
                {
                    return 1;
                }
                else
                {
                    return -1;
                }
            }