+ ZOOM_resultset_sort(ZOOM_resultset r,
+ const char *sort_type, const char *sort_spec)
+{
+ ZOOM_connection c = r->connection;
+ ZOOM_task task;
+
+ if (!c)
+ return;
+
+ if (c->host_port && c->proto == PROTO_HTTP)
+ {
+ if (!c->cs)
+ {
+ yaz_log(log_level, "NO COMSTACK");
+ ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
+ }
+ else
+ {
+ yaz_log(log_level, "PREPARE FOR RECONNECT");
+ c->reconnect_ok = 1;
+ }
+ }
+
+ ZOOM_resultset_cache_reset(r);
+ task = ZOOM_connection_add_task (c, ZOOM_TASK_SORT);
+ task->u.sort.resultset = r;
+ task->u.sort.q = ZOOM_query_create();
+ ZOOM_query_sortby(task->u.sort.q, sort_spec);
+
+ ZOOM_resultset_addref (r);
+
+ if (!c->async)
+ {
+ while (ZOOM_event (1, &c))
+ ;
+ }
+}
+
+ZOOM_API(void)
+ ZOOM_resultset_cache_reset(ZOOM_resultset r)
+{
+ ZOOM_record_cache rc;
+
+ for (rc = r->record_cache; rc; rc = rc->next)
+ {
+ if (rc->rec.wrbuf_marc)
+ wrbuf_free (rc->rec.wrbuf_marc, 1);
+ if (rc->rec.wrbuf_iconv)
+ wrbuf_free (rc->rec.wrbuf_iconv, 1);
+ if (rc->rec.wrbuf_opac)
+ wrbuf_free (rc->rec.wrbuf_opac, 1);
+ }
+ r->record_cache = 0;
+}
+
+ZOOM_API(void)