#### Task:

Your job here is to write a function (`keepOrder` in JS/CoffeeScript, `keep_order` in Ruby/Crystal/Python, `keeporder` in Julia), which takes a sorted array `ary` and a value `val`, and returns the lowest index where you could insert `val` to maintain the sorted-ness of the array. The input array will always be sorted in ascending order. It may contain duplicates.

_Do not modify the input._

#### Some examples:

```python
keep_order([1, 2, 3, 4, 7], 5) #=> 4
                      ^(index 4)
keep_order([1, 2, 3, 4, 7], 0) #=> 0
          ^(index 0)
keep_order([1, 1, 2, 2, 2], 2) #=> 2
                ^(index 2)
```

Also check out my other creations — [Naming Files](https://www.codewars.com/kata/naming-files), [Elections: Weighted Average](https://www.codewars.com/kata/elections-weighted-average), [Identify Case](https://www.codewars.com/kata/identify-case), [Split Without Loss](https://www.codewars.com/kata/split-without-loss), [Adding Fractions](https://www.codewars.com/kata/adding-fractions),
[Random Integers](https://www.codewars.com/kata/random-integers), [Implement String#transpose](https://www.codewars.com/kata/implement-string-number-transpose), [Implement Array#transpose!](https://www.codewars.com/kata/implement-array-number-transpose), [Arrays and Procs #1](https://www.codewars.com/kata/arrays-and-procs-number-1), and [Arrays and Procs #2](https://www.codewars.com/kata/arrays-and-procs-number-2).

If you notice any issues or have any suggestions/comments whatsoever, please don't hesitate to mark an issue or just comment. Thanks!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def keep_order(ary, val):
	

Solutions:
from bisect import bisect_left as keep_order


from bisect import bisect_left

def keep_order(arr, val):
	return bisect_left(arr, val)


def keep_order(ary, val):
	for (i, x) in enumerate(ary):
		if x >= val:
			return i
	return len(ary)


def keep_order(arr, val):
	for i in range(len(arr)):
		if arr[i] >= val:
			return i
	return len(arr)


def keep_order(ary, val):
	return len(list((x for x in ary if x < val)))


def keep_order(ary, val):
	for (i, _) in enumerate(ary):
		if val <= ary[i]:
			return i
	return len(ary)


def keep_order(ar, val):
	for i in range(len(ar)):
		if ar[i] >= val:
			return i
	return len(ar)


def keep_order(a, value):
	for i in range(len(a)):
		if value <= a[i]:
			return i
	return len(a)


def keep_order(ary, val):
	return sum((i < val for i in ary))


def keep_order(ary, val):
	if not ary:
		return 0
	for x in range(len(ary)):
		if val <= ary[x]:
			return x
	return x + 1


def keep_order(ary, val):
	ary.append(val)
	return sorted(ary).index(val)


def keep_order(ary, val):
	return next((ary.index(x) for x in ary if x >= val), len(ary))


def keep_order(ary, val):
	if not ary:
		return 0
	if max(ary) < val:
		return len(ary)
	for (i, num) in enumerate(ary):
		if num >= val:
			return i


def keep_order(ary, val):
	print(ary, val)
	a = ary
	a.append(val)
	a.sort()
	for (i, j) in enumerate(a):
		if j == val:
			return i


def keep_order(ary, val):
	return next((i for (i, (v1, v2)) in enumerate(zip(ary, ary[1:]), 1) if v1 <= val <= v2), len(ary)) if ary and val > ary[0] else 0


def keep_order(ary, val):
	idx = 0
	for i in range(len(ary)):
		if val > ary[idx]:
			idx += 1
		else:
			return idx
	return idx


from itertools import takewhile

def keep_order(ary, val):
	return len(list(takewhile(lambda v: v < val, ary)))


def keep_order(ary, val):
	if val not in ary:
		ary.append(val)
	ary.sort()
	return ary.index(val)


def keep_order(a, x):
	for (i, v) in enumerate(a):
		if v >= x:
			return i
	return len(a)