Sorts posts, pages, and static files.
5267
def sort_files!
      site.collections.each_value { |c| c.docs.sort! }
      site.pages.sort_by!(&:name)
      site.static_files.sort_by!(&:relative_path)
    end
828640
function filterFiles(files, recursive) {
    var fileOrDir = function fileOrDir(lstat) {
        return lstat.isFile() || lstat.isDirectory();
    };
    return files.filter(function (_ref) {
        var lstat = _ref.lstat;

        return recursive ? fileOrDir(lstat) : lstat.isFile();
    });
}
1020734
function removePostsContent( posts, options ) {

	var _sortPosts = options && typeof options.sortPosts === 'function' ?
				options.sortPosts : sortPosts,
			i = 0,
			len = 0;

	// Posts should be objects separated by commas but not wrapped in []
	posts = JSON.parse( '[' + posts.contents.toString() + ']' );

	len = posts.length;

	for ( i; i < len; i++ ) {

		delete posts[i].content;
	}

	// Sort posts by newest
	posts.sort( _sortPosts );

	return JSON.stringify( posts );
}
448471
public void sort() {

        Collections.sort(m_appConfigurations, new ConfigurationComparator<I_CmsWorkplaceAppConfiguration>());
        Collections.sort(m_children, new ConfigurationComparator<CmsAppCategoryNode>());
    }
808447
function query_posts()
   	{
   		// vars
   		$r = array(
   			'next_page_exists' => 1,
   			'html' => ''
   		);
   		
   		
   		// options
		$options = array(
			'post_type'					=>	'all',
			'taxonomy'					=>	'all',
			'posts_per_page'			=>	10,
			'paged'						=>	1,
			'orderby'					=>	'title',
			'order'						=>	'ASC',
			'post_status'				=>	'any',
			'suppress_filters'			=>	false,
			's'							=>	'',
			'lang'						=>	false,
			'update_post_meta_cache'	=>	false,
			'field_key'					=>	'',
			'nonce'						=>	'',
			'ancestor'					=>	false,
		);
		
		$options = array_merge( $options, $_POST );
		
		
		// validate
		if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
		{
			die();
		}
		
		
		// WPML
		if( $options['lang'] )
		{
			global $sitepress;
			
			if( !empty($sitepress) )
			{
				$sitepress->switch_lang( $options['lang'] );
			}
		}
		
		
		// convert types
		$options['post_type'] = explode(',', $options['post_type']);
		$options['taxonomy'] = explode(',', $options['taxonomy']);
		
		
		// load all post types by default
		if( in_array('all', $options['post_type']) )
		{
			$options['post_type'] = apply_filters('acf/get_post_types', array());
		}
		
		
		// attachment doesn't work if it is the only item in an array???
		if( is_array($options['post_type']) && count($options['post_type']) == 1 )
		{
			$options['post_type'] = $options['post_type'][0];
		}
		
		
		// create tax queries
		if( ! in_array('all', $options['taxonomy']) )
		{
			// vars
			$taxonomies = array();
			$options['tax_query'] = array();
			
			foreach( $options['taxonomy'] as $v )
			{
				
				// find term (find taxonomy!)
				// $term = array( 0 => $taxonomy, 1 => $term_id )
				$term = explode(':', $v); 
				
				
				// validate
				if( !is_array($term) || !isset($term[1]) )
				{
					continue;
				}
				
				
				// add to tax array
				$taxonomies[ $term[0] ][] = $term[1];
				
			}
			
			
			// now create the tax queries
			foreach( $taxonomies as $k => $v )
			{
				$options['tax_query'][] = array(
					'taxonomy' => $k,
					'field' => 'id',
					'terms' => $v,
				);
			}
		}
		
		unset( $options['taxonomy'] );
		
		
		// load field
		$field = array();
		if( $options['ancestor'] )
		{
			$ancestor = apply_filters('acf/load_field', array(), $options['ancestor'] );
			$field = acf_get_child_field_from_parent_field( $options['field_key'], $ancestor );
		}
		else
		{
			$field = apply_filters('acf/load_field', array(), $options['field_key'] );
		}
		
		
		// get the post from which this field is rendered on
		$the_post = get_post( $options['post_id'] );
		
		
		// filters
		$options = apply_filters('acf/fields/relationship/query', $options, $field, $the_post);
		$options = apply_filters('acf/fields/relationship/query/name=' . $field['_name'], $options, $field, $the_post );
		$options = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $options, $field, $the_post );
		
		
		// query
		$wp_query = new WP_Query( $options );

		
		// global
		global $post;
		
		
		// loop
		while( $wp_query->have_posts() ) {
			
			$wp_query->the_post();
			
			
			// get title
			$title = $this->get_result($post, $field, $the_post, $options);
			
			
			// update html
			$r['html'] .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title .  '<span class="acf-button-add"></span></a></li>';
				
		}
		
		
		// next page
		if( (int)$options['paged'] >= $wp_query->max_num_pages ) {
			
			$r['next_page_exists'] = 0;
			
		}
		
		
		// reset
		wp_reset_postdata();
		
		
		// return JSON
		echo json_encode( $r );
		
		die();
			
	}
886466
public function index()
    {
        //  Set method info
        $this->data['page']->title = 'Manage ' . ucfirst($this->data['postNamePlural']);

        // --------------------------------------------------------------------------

        $sTableAlias = $this->blog_post_model->getTableAlias();

        // --------------------------------------------------------------------------

        //  Get pagination and search/sort variables
        $iPage      = (int) $this->input->get('page') ? (int) $this->input->get('page') : 0;
        $iPerPage   = (int) $this->input->get('perPage') ? (int) $this->input->get('perPage') : 50;
        $sSortOn    = $this->input->get('sortOn') ? $this->input->get('sortOn') : $sTableAlias . '.published';
        $sSortOrder = $this->input->get('sortOrder') ? $this->input->get('sortOrder') : 'desc';
        $sKeywords  = $this->input->get('keywords') ? $this->input->get('keywords') : '';

        // --------------------------------------------------------------------------

        //  Define the sortable columns
        $aSortColumns = array(
            $sTableAlias . '.published' => 'Published Date',
            $sTableAlias . '.modified'  => 'Modified Date',
            $sTableAlias . '.title'     => 'Title'
        );

        // --------------------------------------------------------------------------

        //  Checkbox filters
        $aCbFilters   = array();
        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.is_published',
            'State',
            array(
                array('Published', true, true),
                array('Unpublished', false, true)
            )
        );

        //  Generate options
        $filterOpts = array();
        foreach ($this->data['postTypes'] as $sValue => $sLabel) {
            $filterOpts[] = array($sLabel, $sValue, true);
        }

        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.type',
            'Type',
            $filterOpts
        );

        // --------------------------------------------------------------------------

        //  Define the $aData variable for the queries
        $aData = array(
            'where' => array(
                array(
                    'column' => 'blog_id',
                    'value' => $this->blog->id
                )
            ),
            'sort' => array(
                array($sSortOn, $sSortOrder)
            ),
            'keywords' => $sKeywords,
            'cbFilters' => $aCbFilters
        );

        //  Get the items for the page
        $iTotalRows          = $this->blog_post_model->countAll($aData);
        $this->data['posts'] = $this->blog_post_model->getAll($iPage, $iPerPage, $aData);

        //  Set Search and Pagination objects for the view
        $this->data['search']     = Helper::searchObject(true, $aSortColumns, $sSortOn, $sSortOrder, $iPerPage, $sKeywords, $aCbFilters);
        $this->data['pagination'] = Helper::paginationObject($iPage, $iPerPage, $iTotalRows);

        //  Add a header button
        if (userHasPermission('admin:blog:post:' . $this->blog->id . ':create')) {

            Helper::addHeaderButton(
                'admin/blog/post/create/' . $this->blog->id,
                'New ' . ucfirst($this->data['postName'])
            );
        }

        // --------------------------------------------------------------------------

        Helper::loadView('index');
    }
1152672
function sortPosts( a, b ) {

	var dateA = new Date( a.created ),
			dateB = new Date( b.created );

	// See if dates match
	if ( dateB - dateA === 0 ) {

		// See if categories are the same
		if ( a.category === b.category ) {

			// Sort by title
			return a.title.localeCompare( b.title );

		// Sort by category
		} else {

			return a.category.localeCompare( b.category );
		}

	// Sort by date descending
	} else {

		return dateB - dateA;
	}
}
939069
function(list, patterns) {

        var sorted = [];
        patterns.forEach(function(p) {
            sorted.push.apply(sorted, list.filter(function(file) {
                return p(file);
            }));
        });

        return sorted;

    }
970723
@SafeVarargs
	public static <T> List<T> sortPageAll(int pageNo, int pageSize, Comparator<T> comparator, Collection<T>... colls) {
		final List<T> list = new ArrayList<>(pageNo * pageSize);
		for (Collection<T> coll : colls) {
			list.addAll(coll);
		}
		if (null != comparator) {
			Collections.sort(list, comparator);
		}

		return page(pageNo, pageSize, list);
	}
883670
public function onSortAttachments()
    {
        if ($sortData = post('sortOrder')) {
            $ids = array_keys($sortData);
            $orders = array_values($sortData);

            $fileModel = $this->getRelationModel();
            $fileModel->setSortableOrder($ids, $orders);
        }
    }
1229711
public function posts()
    {
        $links[] = [__d('me_cms', 'List posts'), [
            'controller' => 'Posts',
            'action' => 'index',
            'plugin' => 'MeCms',
            'prefix' => ADMIN_PREFIX,
        ]];
        $links[] = [__d('me_cms', 'Add post'), [
            'controller' => 'Posts',
            'action' => 'add',
            'plugin' => 'MeCms',
            'prefix' => ADMIN_PREFIX,
        ]];

        //Only admins and managers can access these actions
        if ($this->Auth->isGroup(['admin', 'manager'])) {
            $links[] = [__d('me_cms', 'List categories'), [
                'controller' => 'PostsCategories',
                'action' => 'index',
                'plugin' => 'MeCms',
                'prefix' => ADMIN_PREFIX,
            ]];
            $links[] = [__d('me_cms', 'Add category'), [
                'controller' => 'PostsCategories',
                'action' => 'add',
                'plugin' => 'MeCms',
                'prefix' => ADMIN_PREFIX,
            ]];
        }

        $links[] = [__d('me_cms', 'List tags'), [
            'controller' => 'PostsTags',
            'action' => 'index',
            'plugin' => 'MeCms',
            'prefix' => ADMIN_PREFIX,
        ]];

        return [$links, I18N_POSTS, ['icon' => 'far file-alt']];
    }
276365
private void sort() {
        RangeHashSorter sortMachine;
        sortMachine = new RangeHashSorter(maxRangeValues, filenames);
        sortMachine.quickSort();
        generateBucketIds();
    }
1283254
function sortPosts (posts) {
  return Object.keys(posts).map(function (post) { return posts[post]; })
    .sort(function (a,b) {
      if ( a.date < b.date ) return 1;
      if ( a.date > b.date ) return -1;
      return 0;
    });
}
1052729
private void sortLists(){
		//sort RGBformats
		//if native RGB24 is supported, put it first
		moveToFirstIfNative(RGBformats, V4L4JConstants.IMF_RGB24);
		
		//sort BGRformats
		//if native BGR24 is supported, put it first
		moveToFirstIfNative(BGRformats, V4L4JConstants.IMF_BGR24);
		
		//sort YUV420formats
		//if native YUV420 is supported, put it first
		moveToFirstIfNative(YUV420formats, V4L4JConstants.IMF_YUV420);
		
		//sort YVU420formats
		//if native YVU420 is supported, put it first
		moveToFirstIfNative(YVU420formats, V4L4JConstants.IMF_YVU420);
		
		//sort JPEGformats
		//put native formats first and libvideo converted ones next
		moveNativeFirst(JPEGformats);
		//if native RGB32 is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_RGB32);
		//if native RGB24 is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_RGB24);
		//if native UYVY is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_UYVY);
		//if native YUYV is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_YUYV);
		//if native YUV420P is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_YUV420);
		//if native MJPEG is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_MJPEG);
		//if native JPEG is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_JPEG);
	}
290804
static function cleanup()
    {
        $searchEngine = eZSearch::getEngine();

        if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'cleanup' ) )
        {
            $searchEngine->cleanup();
        }
    }
1134492
function sortPageLinks() {
        var i, len, link,
            destination,
            // the starting and ending page *numbers* (not indexes)
            start = config.pageStart,
            end = config.pageEnd,
            links = config.metadata.links || [],
            sorted = [];

        // NOTE:
        // link.pagenum is the page the link resides on
        // link.destination.pagenum is the page the link links to

        for (i = 0, len = config.metadata.numpages; i < len; ++i) {
            sorted[i] = [];
        }

        for (i = 0, len = links.length; i < len; ++i) {
            link = links[i];

            if (link.pagenum < start || link.pagenum > end) {
                // link page is outside the enabled page range
                continue;
            }

            if (link.destination) {
                destination = link.destination.pagenum;

                if (destination < start || destination > end) {
                    // destination is outside the enabled page range
                    continue;
                } else {
                    // subtract the number of pages cut off from the beginning
                    link.destination.pagenum = destination - (start - 1);
                }
            }

            sorted[link.pagenum - 1].push(link);
        }

        return sorted;
    }
791343
def process(parsed_files, opts)
      r = aggregate(parsed_files)
      r = pre_process(r, opts)
      r = to_class_objects(r, opts)
      return post_process(r, opts)
    end