class ImperativeProgramming {
  private ImperativeProgramming() {
  }

  /**
   * Method to return the car models built after year 2000 using for loops.
   *
   * @param cars {@link List} of {@link Car} to iterate over
   * @return {@link List} of {@link String} of car models built after year 2000
   */
  public static List<String> getModelsAfter2000(List<Car> cars) {
    List<Car> carsSortedByYear = new ArrayList<>();

    for (Car car : cars) {
      if (car.year() > 2000) {
        carsSortedByYear.add(car);
      }
    }

    Collections.sort(carsSortedByYear, new Comparator<Car>() {
      @Override
      public int compare(Car car1, Car car2) {
        return car1.year() - car2.year();
      }
    });

    List<String> models = new ArrayList<>();
    for (Car car : carsSortedByYear) {
      models.add(car.model());
    }

    return models;
  }

  /**
   * Method to group cars by category using for loops.
   *
   * @param cars {@link List} of {@link Car} to be used for grouping
   * @return {@link Map} with category as key and cars belonging to that category as value
   */
  public static Map<Category, List<Car>> getGroupingOfCarsByCategory(List<Car> cars) {
    Map<Category, List<Car>> groupingByCategory = new HashMap<>();
    for (Car car : cars) {
      if (groupingByCategory.containsKey(car.category())) {
        groupingByCategory.get(car.category()).add(car);
      } else {
        List<Car> categoryCars = new ArrayList<>();
        categoryCars.add(car);
        groupingByCategory.put(car.category(), categoryCars);
      }
    }
    return groupingByCategory;
  }

  /**
   * Method to get all Sedan cars belonging to a group of persons sorted by year of manufacture
   * using for loops.
   *
   * @param persons {@link List} of {@link Person} to be used
   * @return {@link List} of {@link Car} to belonging to the group
   */
  public static List<Car> getSedanCarsOwnedSortedByDate(List<Person> persons) {<FILL_FUNCTION_BODY>}
}

    List<Car> cars = new ArrayList<>();
    for (Person person : persons) {
      cars.addAll(person.cars());
    }

    List<Car> sedanCars = new ArrayList<>();
    for (Car car : cars) {
      if (Category.SEDAN.equals(car.category())) {
        sedanCars.add(car);
      }
    }

    sedanCars.sort(new Comparator<Car>() {
      @Override
      public int compare(Car o1, Car o2) {
        return o1.year() - o2.year();
      }
    });

    return sedanCars;
  
<no_super_class>