aboutsummaryrefslogtreecommitdiff
path: root/todo/util/array.py
diff options
context:
space:
mode:
Diffstat (limited to 'todo/util/array.py')
-rw-r--r--todo/util/array.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/todo/util/array.py b/todo/util/array.py
new file mode 100644
index 0000000..bb4eee3
--- /dev/null
+++ b/todo/util/array.py
@@ -0,0 +1,5 @@
+def insert_position(x, xs, is_reversed: bool) -> int:
+ for i, y in enumerate(xs):
+ if is_reversed and x >= y or not is_reversed and x <= y:
+ return i
+ return len(xs)