I want to sort my repositories search result by the date they are created. This might be an easy task but I have been struggling for a while. Please help :(
            Asked
            
        
        
            Active
            
        
            Viewed 5,416 times
        
    4
            
            
        - 
                    You are wanting to "Sort Javascript Object Array By Date": https://stackoverflow.com/questions/10123953/sort-javascript-object-array-by-date, https://stackoverflow.com/questions/19430561/how-to-sort-a-javascript-array-of-objects-by-date, https://stackoverflow.com/questions/40965727/sort-array-of-objects-with-date-field-by-date – ESR Nov 13 '17 at 01:34
2 Answers
5
            If Github API Graphql v4 is still an option, you can do this very easily, from the explorer :
{
  user(login: "bertrandmartel") {
    repositories(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {
      nodes {
        createdAt
        name
      }
    }
  }
}
using curl :
curl -H "Authorization: bearer token" -d '
 {
   "query": "query { user(login: \"bertrandmartel\") { repositories(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) { nodes { createdAt name } } } }"
 }
' https://api.github.com/graphql
 
    
    
        Bertrand Martel
        
- 42,756
- 16
- 135
- 159
4
            
            
        For API (V3) you can include the sort qualifier in your query -  +sort:author-date-desc for descending and +sort:author-date-asc for ascending. 
For example: to search all repos started by km-poonacha sorted ascending you can make the following search request: 
https://api.github.com/search/repositories?q=user:km-poonacha+sort:author-date-asc
 
    
    
        Poonacha
        
- 1,267
- 1
- 8
- 24
