<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>You can define a function that returns an ordervalue on any metadata field. &nbsp;It'll look like this:</div>
<div><br>
</div>
<div>....</div>
<div>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>name =&gt; 'foo',</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>type =&gt; 'name',</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>multiple =&gt; 0,</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>make_value_orderkey =&gt; 'my_order_function'</div>
<div>}</div>
<div>...</div>
<div><br>
</div>
<div><br>
</div>
<div>$c-&gt;{my_order_function} = sub</div>
<div>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>my ($field, $value, $session, $langid, $dataset) = @_;</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>$familyname = $value-&gt;{family};</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>return md5($family);</div>
<div>}</div>
<div><br>
</div>
<div>Note that this is hazy, from memory and just typed straight into the email. &nbsp;Also, don't forget to regenerate the order values (I believe it's an epadmin command).</div>
<div><br>
</div>
<div>
<div id="">
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="font-family: Calibri;">
<tbody>
<tr>
<td valign="top" style="border-style: solid none none; border-top-color: rgb(44, 56, 65); border-top-width: 1pt; padding: 0cm 0cm 3pt;">
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<a href="http://www.jisc.ac.uk/" style="color: rgb(149, 79, 114);"><span style="font-size: 12pt; font-family: 'Times New Roman', serif; color: blue; text-decoration: none;"><img border="0" width="60" height="35" id="Picture_x0020_1" src="cid:34FA2E08-61DE-4B48-AF25-38ECEAD2459E" alt="Jisc" type="image/png"></span></a><span style="font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p></o:p></span></p>
</td>
</tr>
<tr>
<td valign="top" style="padding: 7.5pt 0cm 0cm;">
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="font-size: 12pt; font-family: Corbel, sans-serif; color: rgb(44, 56, 65);">Adam Field</span></b><span style="font-size: 12pt; font-family: 'Times New Roman', serif;"><br>
</span><span style="font-size: 12pt; font-family: Corbel, sans-serif; color: rgb(44, 56, 65);">SHERPA services analyst developer</span></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>&lt;<a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a>&gt; on behalf of &quot;Alan.Stiles&quot; &lt;<a href="mailto:alan.stiles@open.ac.uk">alan.stiles@open.ac.uk</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>&quot;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&quot; &lt;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Wednesday, 20 April 2016 16:01<br>
<span style="font-weight:bold">To: </span>&quot;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&quot; &lt;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [EP-tech] Search results sorting by compound field elements<br>
</div>
<div><br>
</div>
<div xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Half-answering my own question:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">my %options = (&quot;custom_order&quot; =&gt; &quot;name&quot;);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">my $list = $ds-&gt;search(%options);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">actually does what I want, but doesn’t resolve the larger question of sorting by sub-fields – e.g. if I wanted to sort the list by given name rather than family name…<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-fareast-language:EN-GB">
<a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> [<a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">mailto:eprints-tech-bounces@ecs.soton.ac.uk</a>]
<b>On Behalf Of </b>Alan.Stiles<br>
<b>Sent:</b> 20 April 2016 15:28<br>
<b>To:</b> <a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a><br>
<b>Subject:</b> [EP-tech] Search results sorting by compound field elements<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<p class="MsoNormal">Anyone got a clue how to format the ‘custom_order’ parameter of a dataset search query to sort by sub-fields of a compound field?<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">i.e. – running a search over the ‘user’ dataset and I want to sort the results by name_family then name_given of the compound ‘name’ field.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Currently running (based on the search method from <a href="http://wiki.eprints.org/w/API:EPrints/DataSet#Object_Methods">
http://wiki.eprints.org/w/API:EPrints/DataSet#Object_Methods</a> ):<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">$list = $ds-&gt;search( {“custom_order” =&gt; “name_given/name_family” };<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">But it doesn’t seem to be sorting the list at all<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Alan<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family: 'Times New Roman', serif;">-- The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England &amp; Wales and a charity registered in Scotland (SC 038302). The Open University
 is authorised and regulated by the Financial Conduct Authority. <o:p></o:p></span></p>
</div>
</div>
</div>
</span>
<font size="1"> <font face="Corbel">   <br />
Jisc is a registered charity (number 1149740) and a company limited by guarantee which is registered in England under Company No. 5747339, VAT No. GB 197 0632 86. Jisc’s registered office is: One Castlepark, Tower Hill, Bristol, BS2 0JA. T 0203 697 5800.<br /><br />
 
Jisc Services Limited is a wholly owned Jisc subsidiary and a company limited by guarantee which is registered in England under company number 2881024, VAT number GB 197 0632 86. The registered office is: One Castle Park, Tower Hill, Bristol BS2 0JA. T 0203 697 5800.
 
    
</font></font></body>
</html>