working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,157 snippets matching: sorting

    public by lbottaro  4520  5  7  5

    How to sort a Javascript array parsing elements using regex pattern

    The Javascript Array.sort() method accepts a callback function to compare two elements of the array using a specific logic. The callback function below may help you in sorting an array matching a particular regular expression pattern. The format of elements in array is x/y/z, where x, y and z are integers, eg "5/10/2". I need to sort the eleme
    var myCompare = function(a,b) {
    	var matchPattern_A = /^([0-9]+)\/([0-9]+)\/([0-9]+)$/g.exec(a);
    	var matchPattern_B = /^([0-9]+)\/([0-9]+)\/([0-9]+)$/g.exec(b);
    
    	if(matchPattern_A && matchPattern_B)
    	{
    		//Apply regex sort
    		//I need to sort based on match[1], match[2], match[3]
    		console.log('Apply regex sort');
    
    		if (parseInt(matchPattern_A[1], 10) < parseInt(matchPattern_B[1], 10))
    			return -1;
    		if (parseInt(matchPattern_A[1], 10) > parseInt(matchPattern_B[1], 10))
    			return 1;
    		else {
    			if (parseInt(matchPattern_A[2], 10) < parseInt(matchPattern_B[2], 10))
    				return -1;
    			if (parseInt(matchPattern_A[2], 10) > parseInt(matchPattern_B[2], 10))
    				return 1;
    			else {
    				if (parseInt(matchPattern_A[3], 10) < parseInt(matchPattern_B[3], 10))
    					return -1;
    				if (parseInt(matchPattern_A[3], 10) > parseInt(matchPattern_B[3], 10))
    					return 1;
    				return 0;
    			}
    		}
    	}
    	else {
    		//Apply basic lexicographic sort
    		console.log('Apply basic lexicographic sort');
    		if (a < b)
    			return -1;
    		if (a > b)
    			return 1;
    		return 0;
    	}
    };
    
    var myArr = [ '5/4/30', '5/10/2', '5/4/3', '1/3/8'];
    console.log(myArr);
    myArr.sort(this.myCompare);
    console.log(myArr);
    
    /*  Example,
        having an array as
        ['5/4/30', '5/10/2', '5/4/3', '1/3/8']
        it will be sorted as
        ['1/3/8', '5/4/3', '5/4/30', '5/10/2']
    */            

    public by Geometry  788  0  3  0

    Sort: Sorts the columns of a matrix by sorting keys.

    Sorts the columns of a matrix by sorting keys. The key value for each column. The matrix to be sorted. The comparer to use.
    /// <summary>
    ///   Sorts the columns of a matrix by sorting keys.
    /// </summary>
    /// 
    /// <param name="keys">The key value for each column.</param>
    /// <param name="values">The matrix to be sorted.</param>
    /// <param name="comparer">The comparer to use.</param>
    /// 
    public static TValue[][] Sort<TKey, TValue>(TKey[] keys, TValue[][] values, IComparer<TKey> comparer)
    {
        int[] indices = new int[keys.Length];
        for (int i = 0; i < keys.Length; i++)
            indices[i] = i;
    
        Array.Sort<TKey, int>(keys, indices, comparer);
    
        return values.Submatrix(0, values.Length - 1, indices);
    }

    public by Tim Kinnane  225  0  3  0

    Take a WPDB query result and display it as a table, with headers from data keys. Creates demo menu page to show example table. #wordpress Basic example for previewing results, handy for debugging etc, but doesn't provide much validation, sorting, pagin...

    Take a WPDB query result and display it as a table, with headers from data keys. Creates demo menu page to show example table. #wordpress Basic example for previewing results, handy for debugging etc, but doesn't provide much validation, sorting, pagination etc.: database_table_example.php
    <?php
    
    /**
     * Take a WPDB query result and display it as a table, with headers from data keys.
     * This example only works with ARRAY_A type result from $wpdb query.
     * @param  array                $db_data Result from $wpdb query
     * @return bool                          Success, outputs table HTML
     * @author Tim Kinnane <tim@nestedcode.com>
     * @link   http://nestedcode.com
     */
    function data_table( $db_data ) {
    	if ( !is_array( $db_data) || empty( $db_data ) ) return false;
    
    	// Get the table header cells by formatting first row's keys
    	$header_vals = array();
    	$keys = array_keys( $db_data[0] );
    	foreach ($keys as $row_key) {
    		$header_vals[] = ucwords( str_replace( '_', ' ', $row_key ) ); // capitalise and convert underscores to spaces
    	}
    	$header = "<thead><tr><th>" . join( '</th><th>', $header_vals ) . "</th></tr></thead>";
    
    	// Make the data rows
    	$rows = array();
    	foreach ( $db_data as $row ) {
    		$row_vals = array();
    		foreach ($row as $key => $value) {
    
    			// format any date values properly with WP date format
    			if ( strpos( $key, 'date' ) !== false || strpos( $key, 'modified' ) !== false ) {
    				$date_format = get_option( 'date_format' );
    				$value = mysql2date( $date_format, $value );
    			}
    			$row_vals[] = $value;
    		}
    		$rows[] = "<tr><td>" . join( '</td><td>', $row_vals ) . "</td></tr>";
    	}
    
    	// Put the table together and output
    	echo '<table class="wp-list-table widefat fixed posts">' . $header . '<tbody>' . join( $rows ) . '</tbody></table>';
    
    	return true;
    }
    
    /* Example usage with a menu page */
    function database_table_example_page() {
    
    	// example query: Posts published in last month
    	global $wpdb;
    	$posts_one_month = $wpdb->get_results("
    		SELECT `ID`, `post_title`, `post_modified`
    		FROM $wpdb->posts
    		WHERE $wpdb->posts.post_type = 'post'
    		AND $wpdb->posts.post_date > '" . date('Y-m-d H:i:s', strtotime('-1 month')) . "'
    		ORDER BY $wpdb->posts.post_date DESC
    	", ARRAY_A );
    
    	?>
    		<div class="wrap">
    			<h1>Last Month's Posts</h1>
    			<?php data_table( $posts_one_month ); ?>
    		</div>
    	<?php
    }
    
    /* Register menu page to use for example */
    function register_example_page() {
      add_menu_page( 'Database Table Example', 'DB Table (demo)', 'manage_options', 'example', 'database_table_example_page', 'dashicons-list-view', 90 );
    }
    add_action( 'admin_menu', 'register_example_page' );
    
    ?>
    
    

    public by Rafael G  3915  3  3  0

    #sort #sorting #puc apc-b 2016

    #sort #sorting #puc apc-b 2016: mergesort.c
    #include <stdio.h>
    
    void merge(int v[], int inicio, int meio, int fim) {
      int aux[100];
      int aux_inicio = inicio, aux_meio = meio + 1, k=0;
      while(aux_inicio <= meio && aux_meio <= fim)
        if(v[aux_inicio] <= v[aux_meio])
          aux[k++] = v[aux_inicio++];
        else
          aux[k++] = v[aux_meio++];
          
      for(aux_inicio = aux_inicio; aux_inicio <= meio; aux_inicio++)
        aux[k++] = v[aux_inicio];
        
      for(aux_meio = aux_meio; aux_meio <= fim; aux_meio++)
        aux[k++] = v[aux_meio];
        
      k=0;
      
      for(aux_inicio = inicio; aux_inicio <= fim; aux_inicio++) //copia aux para v
        v[aux_inicio] = aux[k++];
    }
    
    void merge_sort(int v[], int inicio, int fim) {
      int meio = (inicio + fim) / 2;
      if(inicio < fim) {
          merge_sort(v, inicio, meio);
          merge_sort(v, meio + 1, fim);
          merge(v, inicio, meio, fim);
        }
    }
    
    int main (void) {
      int var[] = {0, 6, 4, 2, 16, 22, 3, 9};
      merge_sort(var, 0, 7);
      int i;
      for (i = 0; i < 8; i++)
        printf("%d ", var[i]);
      return 0;
    }
    
    

    public by cghersi  2609  1  5  0

    Index Usage Reporter

    Util_IndexUsage Thanks to Jesse Roberge - YeshuaAgapao@Yahoo.com Update - Fixed existance check for drop Reports index stats, index size+rows, member seek + include columns as two comma separated output columns, and index usage stats for one or more tables and/or schemas. Flexible parameterized sorting. Has all the output of Util_ListIndexes
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    SET ANSI_PADDING ON
    GO
    
    IF OBJECT_ID('dbo.Util_IndexUsage', 'P') IS NOT NULL DROP PROCEDURE dbo.Util_IndexUsage
    GO
    
    /**
    *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
    Util_IndexUsage
    By Jesse Roberge - YeshuaAgapao@Yahoo.com
    Update - Fixed existance check for drop
    
    Reports index stats, index size+rows, member seek + include columns as two comma separated output columns, and index usage stats for one or more tables and/or schemas.  Flexible parameterized sorting.
    Has all the output of Util_ListIndexes plus the usage stats.
    
    Update 2009-01-14:
    	Added IndexDepth and FillFactor output columns
    	Added 'Last xxx' datetime columns to the result set
    	Added @Delimiter parameter for the column listing output (Defaults to ,) for accomodating export to csv files.
    	Rearranged collumn output to match the pattern in Util_MissingIndexes. Constistant and looks better with the dates.
    	Removed duplicate output of 'is_unique'
    
    Required Input Parameters
    	none
    
    Optional
    	@SchemaName sysname=''		Filters schemas.  Can use LIKE wildcards.  All schemas if blank.  Accepts LIKE Wildcards.
    	@TableName sysname=''		Filters tables.  Can use LIKE wildcards.  All tables if blank.  Accepts LIKE Wildcards.
    	@Sort Tinyint=5				Determines what to sort the results by:
    									Value	Sort Columns
    									1		Score DESC, user_seeks DESC, user_scans DESC
    									2		Score ASC, user_seeks ASC, user_scans ASC
    									3		SchemaName ASC, TableName ASC, IndexName ASC
    									4		SchemaName ASC, TableName ASC, Score DESC
    									5		SchemaName ASC, TableName ASC, Score ASC
    	@Delimiter VarChar(1)=','	Delimiter for the horizontal delimited seek and include column listings.
    
    Usage:
    	EXECUTE Util_IndexUsage 'dbo', 'order%', 5, '|'
    
    Copyright:
    	Licensed under the L-GPL - a weak copyleft license - you are permitted to use this as a component of a proprietary database and call this from proprietary software.
    	Copyleft lets you do anything you want except plagarize, conceal the source, proprietarize modifications, or prohibit copying & re-distribution of this script/proc.
    
    	This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU Lesser General Public License as
        published by the Free Software Foundation, either version 3 of the
        License, or (at your option) any later version.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU Lesser General Public License for more details.
    
        see <http://www.fsf.org/licensing/licenses/lgpl.html> for the license text.
    
    *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
    **/
    
    CREATE PROCEDURE dbo.Util_IndexUsage
    	@SchemaName SysName='',
    	@TableName SysName='',
    	@Sort tinyint=5,
    	@Delimiter VarChar(1)=','
    AS
    
    SELECT
    	sys.schemas.schema_id, sys.schemas.name AS schema_name,
    	sys.objects.object_id, sys.objects.name AS object_name,
    	sys.indexes.index_id, ISNULL(sys.indexes.name, '---') AS index_name,
    	partitions.Rows, partitions.SizeMB, IndexProperty(sys.objects.object_id,
    	sys.indexes.name, 'IndexDepth') AS IndexDepth,
    	sys.indexes.type, sys.indexes.type_desc, sys.indexes.fill_factor,
    	sys.indexes.is_unique, sys.indexes.is_primary_key, sys.indexes.is_unique_constraint,
    	ISNULL(Index_Columns.index_columns_key, '---') AS index_columns_key,
    	ISNULL(Index_Columns.index_columns_include, '---') AS index_columns_include,
    	ISNULL(sys.dm_db_index_usage_stats.user_seeks,0) AS user_seeks,
    	ISNULL(sys.dm_db_index_usage_stats.user_scans,0) AS user_scans,
    	ISNULL(sys.dm_db_index_usage_stats.user_lookups,0) AS user_lookups,
    	ISNULL(sys.dm_db_index_usage_stats.user_updates,0) AS user_updates,
    	sys.dm_db_index_usage_stats.last_user_seek, sys.dm_db_index_usage_stats.last_user_scan,
    	sys.dm_db_index_usage_stats.last_user_lookup, sys.dm_db_index_usage_stats.last_user_update,
    	ISNULL(sys.dm_db_index_usage_stats.system_seeks,0) AS system_seeks,
    	ISNULL(sys.dm_db_index_usage_stats.system_scans,0) AS system_scans,
    	ISNULL(sys.dm_db_index_usage_stats.system_lookups,0) AS system_lookups,
    	ISNULL(sys.dm_db_index_usage_stats.system_updates,0) AS system_updates,
    	sys.dm_db_index_usage_stats.last_system_seek, sys.dm_db_index_usage_stats.last_system_scan,
    	sys.dm_db_index_usage_stats.last_system_lookup, sys.dm_db_index_usage_stats.last_system_update,
    	(
    		(
    			(CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_seeks,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_seeks,0)))*10
    			+ CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_scans,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_scans,0)))*1 ELSE 0 END
    			+ 1
    		)
    		/CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_updates,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_updates,0))+1) ELSE 1 END
    	) AS Score
    FROM
    	sys.objects
    	JOIN sys.schemas ON sys.objects.schema_id=sys.schemas.schema_id
    	JOIN sys.indexes ON sys.indexes.object_id=sys.objects.object_id
    	JOIN (
    		SELECT
    			object_id, index_id, SUM(row_count) AS Rows,
    			CONVERT(numeric(19,3), CONVERT(numeric(19,3), SUM(in_row_reserved_page_count+lob_reserved_page_count+row_overflow_reserved_page_count))/CONVERT(numeric(19,3), 128)) AS SizeMB
    		FROM sys.dm_db_partition_stats
    		GROUP BY object_id, index_id
    	) AS partitions ON sys.indexes.object_id=partitions.object_id AND sys.indexes.index_id=partitions.index_id
    	CROSS APPLY (
    		SELECT
    			LEFT(index_columns_key, LEN(index_columns_key)-1) AS index_columns_key,
    			LEFT(index_columns_include, LEN(index_columns_include)-1) AS index_columns_include
    		FROM
    			(
    				SELECT
    					(
    						SELECT sys.columns.name + @Delimiter + ' '
    						FROM
    							sys.index_columns
    							JOIN sys.columns ON
    								sys.index_columns.column_id=sys.columns.column_id
    								AND sys.index_columns.object_id=sys.columns.object_id
    						WHERE
    							sys.index_columns.is_included_column=0
    							AND sys.indexes.object_id=sys.index_columns.object_id
    							AND sys.indexes.index_id=sys.index_columns.index_id
    						ORDER BY key_ordinal
    						FOR XML PATH('')
    					) AS index_columns_key,
    					(
    						SELECT sys.columns.name + @Delimiter + ' '
    						FROM
    							sys.index_columns
    							JOIN sys.columns ON
    								sys.index_columns.column_id=sys.columns.column_id
    								AND sys.index_columns.object_id=sys.columns.object_id
    						WHERE
    							sys.index_columns.is_included_column=1
    							AND sys.indexes.object_id=sys.index_columns.object_id
    							AND sys.indexes.index_id=sys.index_columns.index_id
    						ORDER BY index_column_id
    						FOR XML PATH('')
    					) AS index_columns_include
    			) AS Index_Columns
    	) AS Index_Columns
    	LEFT OUTER JOIN sys.dm_db_index_usage_stats ON
    		sys.indexes.index_id=sys.dm_db_index_usage_stats.index_id
    		AND sys.indexes.object_id=sys.dm_db_index_usage_stats.object_id
    		AND sys.dm_db_index_usage_stats.database_id=DB_ID()
    WHERE
    	sys.objects.type='u'
    	AND sys.schemas.name LIKE CASE WHEN @SchemaName='' THEn sys.schemas.name ELSE @SchemaName END
    	AND sys.objects.name LIKE CASE WHEN @TableName='' THEn sys.objects.name ELSE @TableName END
    ORDER BY
    	CASE @Sort
    		WHEN 1 THEN
    			(
    				(
    					(CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_seeks,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_seeks,0)))*10
    					+ CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_scans,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_scans,0)))*1 ELSE 0 END
    					+ 1
    				)
    				/CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_updates,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_updates,0))+1) ELSE 1 END
    			)*-1
    		WHEN 2 THEN
    			(
    				(
    					(CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_seeks,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_seeks,0)))*10
    					+ CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_scans,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_scans,0)))*1 ELSE 0 END
    					+ 1
    				)
    				/CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_updates,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_updates,0))+1) ELSE 1 END
    			)
    		ELSE NULL
    	END,
    	CASE @Sort
    		WHEN 3 THEN sys.schemas.name
    		WHEN 4 THEN sys.schemas.name
    		WHEN 5 THEN sys.schemas.name
    		ELSE NULL
    	END,
    	CASE @Sort
    		WHEN 1 THEN CONVERT(VarChar(10), sys.dm_db_index_usage_stats.user_seeks*-1)
    		WHEN 2 THEN CONVERT(VarChar(10), sys.dm_db_index_usage_stats.user_seeks)
    		ELSE NULL
    	END,
    	CASE @Sort
    		WHEN 3 THEN sys.objects.name
    		WHEN 4 THEN sys.objects.name
    		WHEN 5 THEN sys.objects.name
    		ELSE NULL
    	END,
    	CASE @Sort
    		WHEN 1 THEN sys.dm_db_index_usage_stats.user_scans*-1
    		WHEN 2 THEN sys.dm_db_index_usage_stats.user_scans
    		WHEN 4 THEN
    			(
    				(
    					(CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_seeks,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_seeks,0)))*10
    					+ CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_scans,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_scans,0)))*1 ELSE 0 END
    					+ 1
    				)
    				/CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_updates,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_updates,0))+1) ELSE 1 END
    			)*-1
    		WHEN 5 THEN
    			(
    				(
    					(CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_seeks,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_seeks,0)))*10
    					+ CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_scans,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_scans,0)))*1 ELSE 0 END
    					+ 1
    				)
    				/CASE WHEN sys.indexes.type=2 THEN (CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.user_updates,0))+CONVERT(Numeric(19,6), ISNULL(sys.dm_db_index_usage_stats.system_updates,0))+1) ELSE 1 END
    			)
    		ELSE NULL
    	END,
    	CASE @Sort
    		WHEN 3 THEN sys.indexes.name
    		ELSE NULL
    	END
    GO
    
    --*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

    public by Geometry  692  0  4  0

    Sort: Sorts time-censored events considering their time of occurrence and the type of event. Events are first sorted in decreased order of occurrence, and then with failures coming before censoring.

    Sorts time-censored events considering their time of occurrence and the type of event. Events are first sorted in decreased order of occurrence, and then with failures coming before censoring. The time of occurrence for the event. The outcome at the time of event (failure or censored). The weights associated with each event. The i
    /// <summary>
    ///   Sorts time-censored events considering their time of occurrence and the type of event.
    ///   Events are first sorted in decreased order of occurrence, and then with failures coming
    ///   before censoring.
    /// </summary>
    /// 
    /// <param name="time">The time of occurrence for the event.</param>
    /// <param name="output">The outcome at the time of event (failure or censored).</param>
    /// <param name="weights">The weights associated with each event.</param>
    /// 
    /// <returns>The indices of the new sorting.</returns>
    /// 
    public static int[] Sort(ref double[] time, ref SurvivalOutcome[] output, ref double[] weights)
    {
        int[] idx = Sort(ref time, ref output);
        weights = weights.Submatrix(idx);
        return idx;
    }

    public by msdn  112588  0  6  0

    CompareGlyphSizes

    // Comparison function for sorting glyphs by size.
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Drawing.Imaging;
    
    // Comparison function for sorting glyphs by size.
    static int CompareGlyphSizes(ArrangedGlyph a, ArrangedGlyph b)
    {
        const int heightWeight = 1024;
    
        int aSize = a.Height * heightWeight + a.Width;
        int bSize = b.Height * heightWeight + b.Width;
    
        if (aSize != bSize)
            return bSize.CompareTo(aSize);
        else
            return a.Source.Character.CompareTo(b.Source.Character);
    }

    public by msdn  1228  0  6  0

    GetPatientsBySortedRecentVisitTime

    // Recent visit time sorting
    using DoctorsRounds.DataModel;
    using DoctorsRounds.ViewModel;
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Collections.Specialized;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Media.Imaging;
    
    // This variable gives access to the collection of all the patients
    private static ObservableCollection<Patient> _patients_data = new ObservableCollection<Patient>();
    
    // Recent visit time sorting
    public static ObservableCollection<Patient> GetPatientsBySortedRecentVisitTime()
    {
        ObservableCollection<Patient> sorted_patients = new ObservableCollection<Patient>();
        IEnumerable<Patient> query = (from sortedByTime in _patients_data where sortedByTime.AgendaTime < DateTime.Now || sortedByTime.IsVisited == true orderby sortedByTime.AgendaTime descending select sortedByTime).Take(5);
    
        // Enumerate query and add add patients one by one to collection
        foreach (Patient onePatient in query)
        {
            sorted_patients.Add(onePatient);
        }
    
        return sorted_patients;
    }

    public by msdn  1216  0  6  0

    GetPatientsBySortedAgendaTime

    // Agenda time sorting
    using DoctorsRounds.DataModel;
    using DoctorsRounds.ViewModel;
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Collections.Specialized;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Media.Imaging;
    
    // This variable gives access to the collection of all the patients
    private static ObservableCollection<Patient> _patients_data = new ObservableCollection<Patient>();
    
    // Agenda time sorting
    public static ObservableCollection<Patient> GetPatientsBySortedAgendaTime()
    {
        ObservableCollection<Patient> sorted_patients = new ObservableCollection<Patient>();
        IEnumerable<Patient> query = from sortedByTime in _patients_data where sortedByTime.AgendaTime >= DateTime.Now && sortedByTime.IsVisited == false orderby sortedByTime.AgendaTime select sortedByTime;
    
        // Enumerate query and add add patients one by one to collection
        foreach (Patient onePatient in query)
        {
            sorted_patients.Add(onePatient);
        }
    
        return sorted_patients;
    }

    external by Rdilorenzo73  122378  18  3  0

    Vaadin Grid / firebase-collection / column sorting

    Vaadin Grid / firebase-collection / column sorting: example.html
    <template is="dom-bind">
                        <firebase-collection
                            location="https://intense-torch-8084.firebaseio.com/matches"
                            order-by-child="TeamNum"
                            data="{{data}}"></firebase-collection>
                        <vaadin-grid>
                            <table>
                                <colgroup>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                </colgroup>
                                <thead>
                                    <tr>
                                        <th>Key</th>
                                        <th>Match Number</th>
                                        <th>Team Number</th>
                                        <th>Auton_Def_Atmpt</th>
                                        <th>Teleop_HG_Num_Made</th>
                                        <th>Teleop_LG_Num_Made</th>
                                        <th>EndGm_Hng_Atmpt</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <template is="dom-repeat" items="[[data]]" as="match">
                                    <tr>
                                        <td>[[match.__firebaseKey__]]</td>
                                        <td>[[match.MatchNum]]</td>
                                        <td>[[match.TeamNum]]</td>
                                        <td>[[match.Auton_Def_Atmpt]]</td>
                                        <td>[[match.Teleop_HG_Num_Made]]</td>
                                        <td>[[match.Teleop_LG_Num_Made]]</td>
                                        <td>[[match.EndGm_Hng_Atmpt]]</td>
                                    </tr>
                                </template>
                                </tbody>
                            </table>
                        </vaadin-grid>
    
                    </template>
    
    
    • Public Snippets
    • Channels Snippets