first part of the fix for #514
select distinct needs to be provided with an explicit order to return consistent results. ip & active suffices for nodes, but if it's a device with an entry in node_ip we get random results. so also order on boolean node to prefer device entries in that case.
(at the time of writing however none of my devices return a mac address, which might be another bug)