@lilixu one flaw here, because you are an awesome parent, you should assign as big cookies as possible. So I think you should assign cookies in reverse order, though the result is the same. Below is my solution.
def findContentChildren(self, g, s):
i,j = len(g)-1,len(s)-1
count = 0
while (i>=0 and j>=0):
if g[i] <= s[j]:
count += 1
i -= 1
you are right assuming Arrays.sort has O(nlogn) complexity.
Java7 uses double-pivot quicksort for Arrays.sort for primitive types, and uses Timsort for Arrays.sort object types. Dual-pivot quicksort for most of the datasets is O(nlogn), but in worst case it's O(n^2). Space complexity is O(1) for this sorting algo.