generates default sorting code