Prospective fix for crashes when sorting JS arrays on Windows

std::sort doesn't seem to like sorting empty arrays, so check the
size before sorting.

Task-number: QTBUG-33658

Change-Id: I841259939ea3bf850d23c129744c322ed46a95fe
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>