max

A Python module used for interacting with collections of objects using LINQ syntax


max

max(func=lambda x: x)

Finds the maximum in an Enumerable collection. This is an executing function.

Parameters

func : a lambda function used as a key selector to find the maximum over.

Returns

The maximum of the collection

Example


from py_linq import Enumerable

Enumerable([
    {'value': 1},
    {'value': 2},
    {'value': 3}
]).max(lambda x: x['value'])
# 3

# For a string
Enumerable([
    'Alice',
    'Bob',
    'Zeke'
]).max()
# 'Zeke'