Split remove_invalid_fields() into reusable chunks

Splitting `remove_invalid_fields()` into two methods (`get_valid_fields()` / `remove_invalid_fields()`) allows external code to easily extract orderable fields, without copying the algorithm. We (amcat) use this to allow our table-rendering software to determine which columns it can sort.