PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/samcrew/tablesort/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
samcrew / tablesort
Files
5 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/samcrew/tablesort/v0
gno
0.9

Files (5)

  • README.mdmarkdown
  • gnomod.tomltoml
  • render.gnogno
  • tablesort.gnogno
  • tablesort_test.gnogno
tablesort.gnogno
1// Package tablesort provides functionality to render a Markdown table with sortable columns.2// It allows users to click on column headers to sort the table in ascending or descending sort direction.3// The sorting state is managed via URL query parameters.4// It displays an error if the table is malformed (e.g. rows with missing cells).5// Multiple tablesort can be rendered on the same page by using a paramPrefix for each Render (See the Render function).6package tablesort78import (9	"sort"10)1112// rowSorter implements sort.Interface for sorting rows by a specific column.13type rowSorter struct {14	rows      [][]string15	colIndex  int16	ascending bool17}1819func (rs rowSorter) Len() int {20	return len(rs.rows)21}2223func (rs rowSorter) Less(i, j int) bool {24	iCell := rs.rows[i][rs.colIndex]25	jCell := rs.rows[j][rs.colIndex]26	if rs.ascending {27		return iCell < jCell28	}29	return iCell > jCell30}3132func (rs rowSorter) Swap(i, j int) {33	rs.rows[i], rs.rows[j] = rs.rows[j], rs.rows[i]34}3536// SortRows sorts the rows slice by a given column index and direction37func SortRows(rows [][]string, colIndex int, ascending bool) {38	sort.Sort(rowSorter{rows, colIndex, ascending})39}40

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.