	#include <algorithm>
	#include <functional>
	#include <iostream>
	#include <string>
	
	struct TeamStats {
		std::string name;
		float yards_per_game;
		int total_points;
	};
	
	using QuickSortPred = std::function<bool(const TeamStats&, const TeamStats&)>;
	void quickSort(TeamStats* arr, size_t numTeams, QuickSortPred predicate)
	{
		/// NOTE: This is NOT a complete quicksort, it's just to demonstrate
		/// the usage of predicate.
	
		for (size_t i = 0; i < numTeams - 1; ++i) {
			// before: if (arr[i] < arr[i+1])
			if (predicate(arr[i], arr[i+1]))
				std::swap(arr[i], arr[i+1]);
		}
	}
	
	
	int main() {
		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;
		};
		quickSort(arr, 3, sortByYards);
		
		// approach two, write the lambda inline.
		quickSort(arr, 3, [](const TeamStats& lhs, const TeamStats& rhs) -> bool {
			return lhs.total_points < rhs.total_points;
		});
	
		return 0;
	}