private List <Tuple <Street, uint[][]> > getRandomizedBuildingsOrders() { List <Tuple <Street, uint[][]> > buildingList = this.street2Buildings. ToList().SelectMany(pair => { Street street = pair.Key; return(pair.Value.Select(buildingCoordinates => new Tuple <Street, uint[][]> (street, buildingCoordinates) )); }).ToList(); return(buildingList.Select(pair => new { value = pair, rand = random.ContinuousUniform(0, 1) }).OrderBy(pair => pair.rand). Select(pair => pair.value).ToList()); }