Exemplo n.º 1
0
def panda_sort_cmp(a: Panda, b: Panda):
    a_type = a.get_type()
    b_type = b.get_type()

    # make sure the internal one is always first
    if a.is_internal() and not b.is_internal():
        return -1
    if not a.is_internal() and b.is_internal():
        return 1

    # sort by hardware type
    if a_type != b_type:
        return a_type < b_type

    # last resort: sort by serial number
    return a.get_usb_serial() < b.get_usb_serial()