linq.Min

Gets the minimum value in an array

Overloads

  • Object Min ()
  • Object Min (selector)
  • Object Min (selector, comparator)

Object Min ()

Gets the minimum value found in the array, using the default comparator

Example

var myArray = [1,3,4,4,4,5];
//Returns 1
myArray.Min();

Object Min (selector)

Gets the element in the array having the minimum value of the selected property, using the default comparator

Example

var myArray = [{x: 1}, {x: 3}, {x: 4}, {x: 4}, {x: 4}, {x: 5}];
//Returns {x: 1}
myArray.Min("o=>o.x");

Object Min (selector, comparator)

Gets the element in the array having the minimum value of the selected property, using the specified comparator

Example

var myArray = [{x: "Hi"}, {x: "Hello"}, {x: "Hello There!"}];
//Returns {x: "Hi"}
myArray.Min("o=>o.x", "(a, b) => a.length > b.length ? 1 : a.length < b.length ? -1 : 0");

Last edited Sep 24, 2011 at 5:58 AM by mlorbetske, version 1

Comments

No comments yet.