Check if the current selling price is less than that of the previous transactions
profits . sort ( reverse = True ) NEW_LINE while ( len ( transaction ) != 0 and prices [ sell - 1 ] > prices [ transaction [ len ( transaction ) - 1 ] [ 1 ] - 1 ] ) : NEW_LINE INDENT p = transaction [ len ( transaction ) - 1 ] NEW_LINE DEDENT