	#include <algorithm>
	#include <functional>
	#include <iostream>
	#include <string>
	
	struct TeamStats {
		std::string name;
		float yards_per_game;
		int total_points;
	};
	
	int main() {
		std::vector<TeamStats> arr {
			{ "Red",   100, 30, },
			{ "Blue",  150, 10, },
			{ "Green", 200, 20, },
		};
	
		// approach one, store the lambda before hand
		auto sortByYards = [](const TeamStats& lhs, const TeamStats& rhs) -> bool {
			return lhs.yards_per_game < rhs.yards_per_game;
		};
		std::sort(arr.begin(), arr.end(), sortByYards);
		std::cout << "By yards:\n";
		for (auto& it : arr) {
			std::cout << it.yards_per_game << " " << it.name << "\n";
		}
		
		// approach two, write the lambda inline.
		std::sort(arr.begin(), arr.end(), [](const TeamStats& lhs, const TeamStats& rhs) -> bool {
			return lhs.total_points < rhs.total_points;
		});
		std::cout << "By points:\n";
		for (auto& it : arr) {
			std::cout << it.total_points << " " << it.name << "\n";
		}
	
		return 0;
	}