def sortMappingsByTargets()

in common/src/main/scala/com/gu/anghammarad/common/Targets.scala [76:89]


  def sortMappingsByTargets(targets: List[Target], mappings: List[Mapping]): List[Mapping] = {
    mappings.sortBy { mapping =>
      ( appMatches(mapping.targets, targets) && stageMatches(mapping.targets, targets)
      , stackMatches(mapping.targets, targets) && stageMatches(mapping.targets, targets)
      , awsAccountMatches(mapping.targets, targets) && stageMatches(mapping.targets, targets)
      , appMatches(mapping.targets, targets) && shouldDefaultBasedOnStage(mapping.targets, targets)
      , stackMatches(mapping.targets, targets) && shouldDefaultBasedOnStage(mapping.targets, targets)
      , awsAccountMatches(mapping.targets, targets) && shouldDefaultBasedOnStage(mapping.targets, targets)
      , appMatches(mapping.targets, targets)
      , stackMatches(mapping.targets, targets)
      , awsAccountMatches(mapping.targets, targets)
      )
    }.reverse
  }