Speeding Up Scripts: Sorting and Selecting Unique
I often find myself working with large collections of objects, and one challenge that frequently comes up is to distill that collection to a set of unique items. For example, I'm working on a project that involves analyzing a lot of network flow data that I receive with parameters for Source, Destination, Protocol, and Port. For a part of this project, I need to create a bunch of computer objects, with parameters for InboundTCPPorts, InboundUDPPorts, InboundOtherPorts, OutboundTCPPorts, OutboundUDPPorts, and OutboundOtherPorts. To make these computer objects, I need to start by getting all of the unique computers from my input data's Source and Destination fields. That's pretty simple. I start by combining the source and destination fields into a single array: $computers = $data.source + $data.destination That gives me a single list of all computers that are involved in these network flows, but that list is going to have a ton of duplication in it (si...