Functional approach: where and orderby don't effect the original list

PHOTO EMBED

Sat Oct 16 2021 06:00:26 GMT+0000 (UTC)

Saved by @funcProgramming

Func<int, bool> isOdd = x => x % 2 == 1;
int[] original = { 7, 6, 1 };

var sorted = original.OrderBy(x => x);
var filtered = original.Where(isOdd);

original // => [7, 6, 1]
sorted // => [1, 6, 7]
filtered // => [7, 1]
content_copyCOPY