Skip to content

Instantly share code, notes, and snippets.

@naxty
Created August 8, 2020 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naxty/e5d019972cf34c6a0bfaebe54f6f27c6 to your computer and use it in GitHub Desktop.
Save naxty/e5d019972cf34c6a0bfaebe54f6f27c6 to your computer and use it in GitHub Desktop.
type Category = {
name: string
tags: string[]
}
type Product = {
name: string
description: string
}
let products: Array<Product> =[
{
name: "Foo",
description: "This is the awesome foo product."
},
{
name:"Bar",
description: "The bar product helps you to improve your TypeScript skills! "
}
]
let categories: Array<Category>= [
{
name: "Travel",
tags: ["#travel", "#digitalnomad", "#backpacks"]
},
{
name: 'Electronics',
tags: ['#smartphone', '#iot']
}
]
console.log(sort(categories));
// [ { "name": "Electronics", "tags": [ "#smartphone", "#iot" ] }, { "name": "Travel", "tags": [ "#travel", "#digitalnomad", "#backpacks" ] } ]
console.log(sort(products));
// [ { "name": "Bar", "description": "The bar product helps you to improve your TypeScript skills! " }, { "name": "Foo", "description": "This is the awesome foo product." } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment