Field sort random via PHP I have a image field and use on cycle. 

field.tpl.php:

&lt;?php
?&gt;

&lt;div class="&lt;?php print $classes; ?&gt;"&lt;?php print $attributes; ?&gt;&gt;
  &lt;?php if (!$label_hidden): ?&gt;
    &lt;div class="field-label"&lt;?php print $title_attributes; ?&gt;&gt;&lt;?php print $label ?&gt;:&amp;nbsp;&lt;/div&gt;
  &lt;?php endif; ?&gt;
  &lt;div class="field-items"&lt;?php print $content_attributes; ?&gt;&gt;
    &lt;?php foreach ($items as $delta =&gt; $item): ?&gt;
      &lt;div class="field-item &lt;?php print $delta % 2 ? 'odd' : 'even'; ?&gt;"&lt;?php print $item_attributes[$delta]; ?&gt;&gt;&lt;?php print render($item); ?&gt;&lt;/div&gt;
    &lt;?php endforeach; ?&gt;
  &lt;/div&gt;
&lt;/div&gt;


My field items sorting default alphabetical but i want random. How can i do this?

EDIT: I find this codes, it valid for me? And how can i use this code for my field?

function my_theme_preprocess_field(&amp;$variables, $hook) {
 if($variables['element']['#field_name']=="field_project_release_packages"){
 usort($variables["items"], "_my_theme_sort_package_list");
 }
}

function _my_theme_sort_package_list($a, $b) {
    return $a["#title"] &gt; $b["#title"]; 
}
You should be able to use template_preprocess_field() and shuffle() to do this. This is an example randomizing the entries in field_photo for a theme called dummy:

  function dummy_preprocess_field(&amp;$variables) {
    if ($variables['element']['#field_name'] == 'field_photo') {
      shuffle($variables['items']);
    }
  }


You could also try to replacing you call to usort() in your original code with shuffle($variables["items"]).

The above isn't tested, but I think it should work.