adds recursive portion of sort