Sorts given column names by length in ascending order while those containing string 'id' go first >>> prioritySortColumns(['password', 'userid', 'name', 'id']) ['id', 'userid', 'name', 'password']
(columns)
| 5155 | return filename |
| 5156 | |
| 5157 | def prioritySortColumns(columns): |
| 5158 | """ |
| 5159 | Sorts given column names by length in ascending order while those containing |
| 5160 | string 'id' go first |
| 5161 | |
| 5162 | >>> prioritySortColumns(['password', 'userid', 'name', 'id']) |
| 5163 | ['id', 'userid', 'name', 'password'] |
| 5164 | """ |
| 5165 | |
| 5166 | def _(column): |
| 5167 | return column and re.search(r"^id|id$", column, re.I) is not None |
| 5168 | |
| 5169 | return sorted(sorted(columns, key=len), key=functools.cmp_to_key(lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)) |
| 5170 | |
| 5171 | def getRequestHeader(request, name): |
| 5172 | """ |
no test coverage detected
searching dependent graphs…