Skip to content

Commit c68d522

Browse files
Create prime_order_prioritization_amazonq2.py
1 parent 8802319 commit c68d522

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
10+
#
11+
# Complete the 'sortOrders' function below.
12+
#
13+
# The function is expected to return a STRING_ARRAY.
14+
# The function accepts STRING_ARRAY orderList as parameter.
15+
#
16+
import re, collections
17+
def sortOrders(orderList):
18+
# Write your code here
19+
20+
primes, nonprimes = [], []
21+
22+
for order in orderList:
23+
metadata = order.split()
24+
if re.search('(^\d+$)', metadata[1]):
25+
nonprimes.append(order)
26+
else:
27+
primes.append(order)
28+
primes.sort(key = lambda k : k.split(' ', 1)[1])
29+
return primes + nonprimes

0 commit comments

Comments
 (0)