Most profitable non-overlapping jobs

jobs is a list of (start, end, profit). Two jobs may both be taken if one ends no later than the other starts. Write max_profit(jobs) that returns the largest total profit from a set of compatible jobs.

max_profit([(1, 3, 50), (2, 4, 10), (3, 5, 40), (3, 6, 70)])  ->  120     (1-3 and 3-6)
max_profit([(1, 2, 5)])  ->  5

Sort by end. best[i] is the best profit using the first i jobs; for job i, either skip it or take it plus best of the last job ending at or before its start, found with bisect.

def max_profit(jobs):
    ...