query.push({attribute: attr1, descending: attr1type === "descending"}); 

would be a more concise way to render this