added forEach and fixed default compair function for sort.
fixed the pop method and removed debug statements.